I have to match some strings from the given variables. Say I have variable
var x = 'elseif testing';
Now I want get value "testing" from this string. So wrote.
x.match(/^elseif(.*)/);
Late I realized sometimes I do get string:
var x = 'else if testing';
So I wrote expression to match:
x.match(/^else[\s+]if(.*)/);
This works well on browser but not in Node.js. Any reason why ?
else ifandelse \t ifbut notelseif. The+modifier means 1 or more. You want the*modifier which means 0 or more.