Hi,
the following (everything that starts with a dot is) a match:
Code: Select allvar s = ".DS_Store";
var re = new RegExp(/^\.\w+/);
$.writeln(s.match(re) != null); // true
conversely if I put the expression into a string and build the RegExp with it, it doesn't:
Code: Select allvar s = ".DS_Store";
var exp = "^\.\w+"
var re = new RegExp(exp, i);
$.writeln(s.match(re) != null); // false
Do you have any idea about the why?
Thank you!
Davide Barranca
RegExp not working
RegExp not working
Code: Select allvar s = ".DS_Store";
var exp = "^\\.\\w+"
var re = new RegExp(exp, i);
$.writeln(s.match(re) != null); // false
-X
var exp = "^\\.\\w+"
var re = new RegExp(exp, i);
$.writeln(s.match(re) != null); // false
-X
RegExp not working
Great! So I need to escape the \.
Thank you very much xbytor,
Davide
Thank you very much xbytor,
Davide