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

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -