text « replace « Java Regex Q&A

Home
Java Regex Q&A
1.Development
2.find
3.group
4.Match
5.matcher
6.number
7.Operation
8.parse
9.Pattern
10.replace
11.validation
12.word
Java Regex Q&A » replace » text 

1. Replace text in StringBuilder via regex    stackoverflow.com

I would like to replace some texts in StringBuilder. How to do this? In this code I got java.lang.StringIndexOutOfBoundsException at line with matcher.find():

StringBuilder sb = new StringBuilder(input);
Pattern pattern ...

2. How to use in replacement String in replaceAll method a matched text?    stackoverflow.com

I would like to add some text after matched pattern in String. How can I do this? for example: String text = text.replaceAll("a[0-9]*z",???+"ADDED"); // a123z -> a123zADDED

3. Java: replace "[" "]" from text files strings    stackoverflow.com

I'm using

str.replaceAll("GeoData[", "");
to replace "[" symbol in some strings in my text file, but I get:
Exception in thread "main" java.util.regex.PatternSyntaxException: Unclosed character class near index 7
GeoData[
      ...

4. regular expressions for replacing text with sms language text    forums.oracle.com

Hi, I'm trying to write a function which converts normal, correctly spelled text into the shorter sms language format but struggling to come up with the regular expressions i need to do so, can anyone help? 1: remove surplus white space at the beginning of a sentence and at the end of a sentence. e.g. " hello." --> "hello." OR "hello ...

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.