0

I am using javascript's replace function.

string.replace(searchvalue, newvalue)

This is the syntax and from what I understand searchvalue can be a regular expression. How do I handle the case when my searchvalue contains square brackets but it shouldn't be considered as a character class?

Example:

seachvalue = abc[xyz]def
newvalue = abcabc[xyz]defdef
string.replace(searchvalue, newvalue)

When I try to use this, it gives me an error because it is considering [xyz] in searchvalue as character class. How do I specify that it is not so?

P.S Other questions related to this are more to do with the content within brackets.

vss
  • 567
  • 2
  • 7
  • 18

0 Answers0