RegExp strange behaviour
Hello everyone.
Maybe I am wrong in the basics of RegExp but, everything mentioned below works perfectly under php's eregi.
The task is quite simple, I need to replace [b] & [/b] like tags into <b> & </b>
This doesn't work. [ & ] just doesn't disappear from the text. It looks like shielding doesn't work and JS thinks that i'm trying to use
var re2 = new RegExp('[b]', "gi").
But more interesting that
(and lots of variants i've tried)
Doesn't work too. I still got [ & ] in the text;
2 days of googling did't bring the answer, so I believe you can help me.
Maybe I am wrong in the basics of RegExp but, everything mentioned below works perfectly under php's eregi.
The task is quite simple, I need to replace [b] & [/b] like tags into <b> & </b>
re2 = new RegExp('\[b\]', "gi");
text=text.replace(re2,"<b>");
This doesn't work. [ & ] just doesn't disappear from the text. It looks like shielding doesn't work and JS thinks that i'm trying to use
var re2 = new RegExp('[b]', "gi").
But more interesting that
var re2 = new RegExp('\x5Bb\x5D', "gi");
text=text.replace(re2,"<b>");
(and lots of variants i've tried)
Doesn't work too. I still got [ & ] in the text;
2 days of googling did't bring the answer, so I believe you can help me.
