Created
January 6, 2014 13:25
-
-
Save unknownuser88/8282856 to your computer and use it in GitHub Desktop.
search(regexp) Tests for a match in a string. It returns the index of the match, or -1 if not found.
This file contains hidden or 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
//search(regexp) | |
var intRegex = /[0-9 -()+]+$/; | |
var myNumber = '999'; | |
var isInt = myNumber.search(intRegex); | |
console.log(isInt); | |
//output: 0 | |
var myString = '999 JS Coders'; | |
var isInt = myString.search(intRegex); | |
console.log(isInt); | |
//output: -1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment