Topic: Javascript regex problem, escaping '[' doesn't work

i'm trying to match and replace a string containing '[' in javascript like so

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <script type="text/javascript">
    var teststr = "This is a test string=[somestuff";
    var rexp = 'string=\[';
    var rex = new RegExp(rexp,"g");
    var newstring = teststr.replace(rex,'okay');
    alert(newstring);
  </script>
</head>

<body>
  TEST  
</body>
</html>

IE and Firfox are both complaining that the '[' isn't closed but i've escaped it so it shouldn't be interpreted as a regex control. Can someone give me a nudge here, I'm sure I'm doing something stupid as I've done plenty of similar things in the past but i've been staring at the screen for the past 30 mins and I just don't see it.

Cheers

Mark

Re: Javascript regex problem, escaping '[' doesn't work

Typical, figured it out literally seconds afterwards.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <script type="text/javascript">
    var teststr = "This is a test string=[somestuff";
    var rex = new RegExp(/string=\[/g);
    var newstring = teststr.replace(rex,'okay');
    alert(newstring);
  </script>
</head>

<body>
  TEST  
</body>
</html>