D
dhek bhun kho
Hi there,
I stumbled on this when I wanted to do a
java.lang.String.replaceAll(String, String) call. The second argument just
says 'replacement' in the API docs.
http://java.sun.com/j2se/1.4.1/docs/api/java/lang/String.html#replaceAll(java.lang.String, java.lang.String)
The API doc is incomplete too! It's missing the description for the second
argument, but whatever the case I can't do something like this:
"hahahahahhaha".replaceAll("(a)(h)","\2\1");
E.g. I want to produce something I'd normally get like this:
$ echo "hahahaha" | sed "s/\(h\)\(a\)/\2\1/g"
The only way to solve it would imply some relatively lengthy coding with
the Pattern and Matcher classes.
I was wondering if I am overlooking something. Is there no facility to
easily perform regex substitutions using back references? If anybody can
be sure the answer is no: please post.
Greets
Bhun.
I stumbled on this when I wanted to do a
java.lang.String.replaceAll(String, String) call. The second argument just
says 'replacement' in the API docs.
http://java.sun.com/j2se/1.4.1/docs/api/java/lang/String.html#replaceAll(java.lang.String, java.lang.String)
The API doc is incomplete too! It's missing the description for the second
argument, but whatever the case I can't do something like this:
"hahahahahhaha".replaceAll("(a)(h)","\2\1");
E.g. I want to produce something I'd normally get like this:
$ echo "hahahaha" | sed "s/\(h\)\(a\)/\2\1/g"
The only way to solve it would imply some relatively lengthy coding with
the Pattern and Matcher classes.
I was wondering if I am overlooking something. Is there no facility to
easily perform regex substitutions using back references? If anybody can
be sure the answer is no: please post.
Greets
Bhun.