I am needing a bit of assistance in a regular expression I am trying to create, I am usually pretty good with these but this one has me stuck...
I am needing to replace the number 9 in strings on the fly with \d (creating a new regular expression). These are some example strings that can be expected:
X(29)
9(5)
99
X(29)V999S
Now before you answer too quickly, we must not touch the numbers in the brackets... I have looked at a couple of other answers on here and there is probably something in this solution, but I cannot seem to adapt it - Regex for splitting a string using space when not surrounded by single or double quotes
So far I have come up with
line.replaceAll("[^(\\d)]??9[^)]??", "\\d");
which gives me
X(2\d)
\d(5)
\d\d
X(2\d)V\d\d\dS
Anyone have any thoughts.