I find myself puzzled by certain aspects of RegExp
. Can anyone offer some insight? Could there be hidden words within RegExp
that cause a failure to match? My suspicion is that the sequence "slt" contains a clandestine symbol that sabotages the success of the RegExp
.
Here's a demonstration to experiment with: click here for demo
//this doesn't work
var funcArgString="c09__id slt ccc";
var myRegExp = new RegExp("([^ \s]*) ([^ \s]*) ([^ \s]*)","g");
alert(myRegExp.exec(funcArgString));
//this works... but why?
var funcArgString="c09__id abcdefg ccc";
var myRegExp = new RegExp("([^ \s]*) ([^ \s]*) ([^ \s]*)","g");
alert(myRegExp.exec(funcArgString));
//this also works
var funcArgString="c09__id slt ccc";
var myRegExp = new RegExp("(.*) (.*) (.*)","g");
alert(myRegExp.exec(funcArgString));