regex to find parenthesis and the numbers within. Java -
what regex used find parenthesis , numbers within these paernthesis?
desired output:
- input =
"hello (1) world".replaceall(regex, "*"); - result =
hello * world
i tried following:
- input =
"hello (1) world".replaceall("([0-9])", "*"); - result = "
"hello (*) world"
why?
( , ) reserved characters in regexes (they create group). need escape them replace them:
"hello (1) world".replaceall("\\([0-9]\\)", "*");
Comments
Post a Comment