Return Receipt
Your R: [WSG] Javascript help with Reg Exp required please
document
When you need the rule to be dynamic you do it this way to recompile the
regular expression:
var txt="foo";
myRe= new RegExp (txt+"\\s", "i");
myArray = myRe.exec("The Foo fooSz Fighers");
alert(myArray)
Notice the \\. It just may be that your way would work with \\ in place
of \. But tech
Return Receipt
Your R: [WSG] Javascript help with Reg Exp required please
document
> var rule2 = eval('/' + txt + '\s/i');
> console.log(str2.match(rule2)); // returns fooSz
Try var rule2 = eval('/' + txt + '\\s/i');
Regards,
Rimantas
--
http://rimantas.com/
***
List Guidelines: http://webstandardsgroup.org/mail
: lunedì 2 giugno 2008 19.44
A: wsg@webstandardsgroup.org
Oggetto: [WSG] Javascript help with Reg Exp required please
Good day all,
Does anyone already get the following issue ?
var str = "The Foo fooSz Fighers";
var rule = /foo\s/i;
console.log(str.match(rule)); // r
Good day all,
Does anyone already get the following issue ?
var str = "The Foo fooSz Fighers";
var rule = /foo\s/i;
console.log(str.match(rule)); // returns Foo
var str2 = "The Foo fooSz Fighers";
var txt = "foo";
var rule2 = eval('/' + txt + '\s/i');
console.log(str2.match(rule2)); // retu