Last active
January 3, 2016 23:29
-
-
Save jgillman/8535512 to your computer and use it in GitHub Desktop.
A node script with confusing output.
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
var re = /s\d{2}/i; | |
var reGlobal = /s\d{2}/gi; | |
var string = 's05'; | |
console.log( 'Testing reGlobal 4 times:' ); | |
console.log( reGlobal.test(string) ); | |
console.log( reGlobal.test(string) ); | |
console.log( reGlobal.test(string) ); | |
console.log( reGlobal.test(string) ); | |
console.log( '\nTesting re 4 times:' ); | |
console.log( re.test(string) ); | |
console.log( re.test(string) ); | |
console.log( re.test(string) ); | |
console.log( re.test(string) ); |
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
Testing reGlobal 4 times: | |
true | |
false | |
true | |
false | |
Testing re 4 times: | |
true | |
true | |
true | |
true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Got an answer on Freenode #Node.js: