Using backreferences in java regular expressions adjacent to digits
I want to use a regexp replace with back references If the target string
is something like:
"$1 123"
every thing works fine. but if I want a target string like:
"$1123"
It wont work.
in perl, you can use
"${1}123"
To distinguish between the back reference an adjacent numbers - is there a
java equivalent?
EDIT
If have time stamps of the format
YYYYMMDDHHMMSS
like:
20130811123000
and I want to reset the hours, minutes, and seconds to get
20130811000000
What I would like to do is
String newstring = timestamp.replaceFirst("(\\d{8}))\\d{6}","${1}000000");
No comments:
Post a Comment