Is it possible to disable support for groups when using appendReplacement in
Matchers ?
Ie, my replacement string contains many uses of the dollar symbol and then
numbers (for money $9 etc) and at the moment I have to first escape that
string before using it as the replacement which seems to be inefficient.
Oliver Wong - 20 Jun 2006 16:53 GMT
> Is it possible to disable support for groups when using appendReplacement
> in Matchers ?
>
> Ie, my replacement string contains many uses of the dollar symbol and then
> numbers (for money $9 etc) and at the moment I have to first escape that
> string before using it as the replacement which seems to be inefficient.
Maybe
http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html#quote(java.
lang.String)
will help?
- Oliver
Jussi Piitulainen - 20 Jun 2006 18:59 GMT
> Is it possible to disable support for groups when using
> appendReplacement in Matchers ?
[quoted text clipped - 3 lines]
> first escape that string before using it as the replacement which
> seems to be inefficient.
You can say
m.appendReplacement(sb, "dog ");
sb.append("$9");