I assume that the first STRING_ONE is a variable contains another string.
STRING_ONE
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-]+$.
\
^[a-z\d-]+$
^[a-z\\d-]+$
STRING_TWO replace word or words from STRING_ONE
But i have too many word to replace.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I assume that the first
STRING_ONE
is a variable contains another string.PS: Make sure to double escape the
\
characters inSTRING_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.