simple java regex with backreference does not work -
i have trouble replace string backreference of regular expression: nothing replaced , end input.
code:
string input="a12.3 bla bla input"; input = stringutils.replacepattern( input, "^([a-z]\\d{2}\\.\\d)", "$1"); system.out.println(input);
the main problem can not change java code input, regex , group reference.
do have suggestions other regex pattern matches needs or going wrong?
stringutils of apache commons lang
you replacing same matched pattern itself. meant:
string input="a12.3 bla bla input"; input = stringutils.replacepattern( input, "^([a-z]\\d{2}\\.\\d).*$", "$1"); // ^^^ system.out.println(input);
.*$
match input till end.
Comments
Post a Comment