View Single Post
Old 12-09-2012, 11:14 AM   PM User | #4
AndrewGSW
Senior Coder

 
Join Date: Apr 2011
Location: London, England
Posts: 2,120
Thanks: 15
Thanked 354 Times in 353 Posts
AndrewGSW will become famous soon enough
Quote:
As with exec (or in combination with it), test called multiple times on the same global regular expression instance will advance past the previous match.
Mozilla
Code:
regexPattern = new RegExp("a","gi");
s = "a";
        alert (regexPattern.test(s));//--> true
        alert(regexPattern.lastIndex); // 1
        alert (regexPattern.test(s));//--> false
        alert(regexPattern.lastIndex); // 0
        alert (regexPattern.test(s));//--> true
        alert(regexPattern.lastIndex); // 1
        alert (regexPattern.test(s));//--> false
        alert(regexPattern.lastIndex); // 0
__________________
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
Validate your HTML and CSS
AndrewGSW is offline   Reply With Quote