I need to replace \d+ and a+ to x, I want to replace all the \d+ to x, but for a+, I only want to replace the first occurance if there's any.
Is it possible to use only one regex to achieve this?
| Input | Desired Output |
|---|---|
123,456,789 |
x,x,x |
123,456,a,789 |
x,x,x,x |
aaa,aa,aaa |
x,aa,aaa |
aa,123,456,aaaa,789 |
x,x,x,aaaa,x |
aaa,123,456,aa,789,aaaa |
x,x,x,aa,x,aaaa |
This sure does not work:
/\d+|a+/gm
I'm using PCRE regex engine, or is there any mode modifier or control verb can do this? Thanks in advance.