I have some troubles with this small JavaScript code:
var text="Z Test Yeah ! Z";
// With literal syntax, it returns true: good!
alert(/(Z[\s\S]*?Z)/g.test(text));
// But not with the RegExp object O_o
var reg=new RegExp('Z[\s\S]*?Z','g');
alert(reg.test(text));
I don't understand why the literal syntax and the RegExp object don't give me the same result... The problem is that I have to use the RegExp object since I'll have some variables later.
Any ideas?
Thanks in advance :)