Reputation: 23
str
is an html string (or string that contains the full html) but with some unwanted codes in between that I tried to get rid off.
This is what worked for me so far:
const contentClean = str.replace(/=0A/gm,"").replace(/(=09)/gm,"").replace(/(=\r\n)/gm,"").replace(/(3D)/gm,"");
How do I write the replace() method just one time instead of 4 times in the code above?
Upvotes: 1
Views: 47
Reputation: 371049
Just alternate between each possibility with |
:
const contentClean = str.replace(/=0A|=09|=\r\n|3D/gm, "");
Note that there's no need for capturing groups.
Upvotes: 1