I'm trying to replace multiple strings in a text file with one string using javascript
I want those two strings "user" and "password" must be replaced with 'replace the string' Anyone help me here?
I'm trying to replace multiple strings in a text file with one string using javascript
I want those two strings "user" and "password" must be replaced with 'replace the string' Anyone help me here?
to add to the previous replies, you can use capture groups to back reference parts of the matched text i.e.
if you search for "user"
let newText = yourText.replace(/^((\"user\")(:".*")(.*))$/gm, '"removed"$3$4' );
if you search for "1232"
let newText = yourText.replace(/^((\".*\")(:"1232")(.*))$/gm, '"removed"$3$4' );