Last active
December 20, 2015 01:49
-
-
Save Bacra/6052267 to your computer and use it in GitHub Desktop.
Test the Test Method of RegExp running in Chrome with the 'g' mdifier
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Test the 'test' Method of RegExp running in Chrome with the 'g' mdifier | |
* the 'exec' method has the same result in chrome | |
* | |
* @author Bacra Woo <Bacra.Woo@gmail.com> | |
*/ | |
var reg = /\d/g; | |
for (var i = 100; i--;) { | |
if (reg.test(i.toString()) === false) console.log(i, 'error'); | |
} | |
console.log('end'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* fixed | |
* | |
* @author Bacra Woo <Bacra.Woo@gmail.com> | |
*/ | |
var reg = /\d/g; | |
for (var i = 100; i--;) { | |
reg.lastIndex = 0; | |
if (reg.test(i.toString()) === false) console.log(i, 'error'); | |
} | |
console.log('end'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* fixed | |
* | |
* @author Bacra Woo <Bacra.Woo@gmail.com> | |
*/ | |
var reg = /\d/; | |
for (var i = 100; i--;) { | |
if (reg.test(i.toString()) === false) console.log(i, 'error'); | |
} | |
console.log('end'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* fixed | |
* | |
* @author Bacra Woo <Bacra.Woo@gmail.com> | |
*/ | |
for (var i = 100; i--;) { | |
if (/\d/g.test(i.toString()) === false) console.log(i, 'error'); | |
} | |
console.log('end'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment