I want to convert some text to something else with replaceall and regular expressions.
My text is like the following:
This is with something extra constraint xhiho,
This is without something extra constraint hfdlh
Now what I want as result is the following:
This is with something extra, --constraint xhiho
This is without something extra -- constraint hfdlh
So I need to put 2 -
before the word constraint and if there is a ,
at the end put it in front of the 2 -
I tried with the following piece of code:
oConvert = oConvert.replaceAll("constraint(.*)(,?)", "$2--constraint$1");
But it is not working, it does not give the ,
in front of the 2 -