I have the below value as a plain text
`[a-zA-Z][a-zA-Z][a-zA-Z][a-zA-Z]sdsds\d\d`
I want to replace all [a-ZA-Z]
with [C]
and replace all \d
with [N]
. I tried to do this with the following code, but it does not work for \d
.
value.replace(/\[a-zA-Z\]/g, '[C]').replace(/\\d/g, '[N]').replaceAll('\d', '[N]')
The final result must be:
[C][C][C][C]asass[N][N]
but it output
[C][C][C][C]s[N]s[N]s[N][N]
Note: I am getting this value from API and there is just one \
before d
not \\
.