loading...
markdown guide
 

I assume that the first STRING_ONE is a variable contains another string.

entered_text.replace(new RegExp(STRING_ONE, 'g'), 'STRING_ONE');

PS: Make sure to double escape the \ characters in STRING_ONE as you are putting regex pattern from string. So, for example, ^[a-z\d-]+$ must be written as ^[a-z\\d-]+$.

 

STRING_TWO replace word or words from STRING_ONE

But i have too many word to replace.

Classic DEV Post from Jan 24

What was your win this week?

Got to all your meetings on time? Started a new project? Fixed a tricky bug?

ivkeMilioner profile image