Friday, 9 August 2013

How to match from the end of the string using regex

How to match from the end of the string using regex

Im not good in regular exp, i want to match a string begginning from the
end of the other string.
var keyword = new Array();
keyword[0] = " void main";
var pool1 = "abdodfo void main";
var pool2 = "abdodfo void main a";
var pool3 = "abdodfo void main ab void mai";
What will be the right regex in the control struct to satisfy the ff:
*should match
if(pool1.match(keyword[0]))
*should NOT match
if(pool2.match(keyword[0]))
if(pool3.match(keyword[0]))
I made this code simpler, i will use this for syntax checking error of my
c++ IDE project.

No comments:

Post a Comment