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

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

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