java - apply escaping for regex matches -


i have such replacement statement

output.replaceall(regex_brackets, "<$2$3>"); 

how apply escaping via (stringescapeutils example) $2 , $3?

here example of how can done inside matcher:

string s = "word 123 text inside next 567"; stringbuffer result = new stringbuffer(); matcher m = pattern.compile("(\\w+)\\s+(\\d+)").matcher(s); while (m.find()) {     string wrd = m.group(1);     string num = m.group(2);     string replacement = wrd.touppercase() + num;     m.appendreplacement(result, replacement); } m.appendtail(result); system.out.println(result.tostring()); 

see ideone demo

just use own functions, using touppercase() demo.


Comments

Popular posts from this blog

apache - setting document root in antoher partition on ubuntu -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -

Process 'command 'F:\android-sdk\build-tools\21.1.2\aapt.exe'' finished with non-zero exit value 1 -