How can I replace all occurences of java substrings like stuff="-9888777666" , stuff="123", with the substring stuff="0"? The double quotes are actually a part of the string.
1 Answer
Have a look at the regular expressions explanation in the java docs:
string = string.replaceAll("stuff=\"-?\\d+\"", "stuff=\"0\"");
2 Comments
soulmerge
\w does not match a dash. Other than that I just ran the code, it replaces your example (
stuff="-9888777666" , stuff="123") perfectly.