I'm new to regular expressions and I have an expression that I have to write for work. I was looking at using replaceAll()
to do this but I'm unsure if I can do what I'm proposing using one regular expression.
I have to change a string in the format of "abc12378"
to "$$$ $$$ 78"
. I can do this with two different regular expressions without issue:
- String:
"abc12378"
- RegEx:
"([1-6])"
- Replacement:
"\$"
- Result:
"$$$$$$78"
Or
- String:
"$$$$$$78"
- RegEx:
"(.{3})"
- Replacement:
"$1 "
- Result:
$$$ $$$ 78
Would you know if I can do this with one combined replaceAll()?
Any help would be much appreciated.