I'm a little rusty in my regex and javascript. I have the following var line:
var subject = "javascript:loadNewsItemWithIndex(5, null);";
I want to extract 5 using regex. This is my regex:
/(?:loadNewsItemWithIndex\()[0-9]+/)
It is applied as follows:
subject.match(/(?:loadNewsItemWithIndex\()[0-9]+/)
Result:
loadNewsItemWithIndex(5
What is the cleanest, most readable way to extract 5 as a single line? Is it possible to do this by excluding loadNewsItemWithIndex( from the match, rather than matching 5 as a subgroup?
Benedict cohen
source share