javascript find number in string 1

javascript find number in string

the regular expression on looks for the first number character in the string

let numberInString = theString.match(/\d+/[0];

Here is what the above code is Doing:
1. We’re using the match() method to find the first number in the string.
2. The regular expression \d+ looks for one or more number characters.
3. The [0] at the end of the expression returns the first number in the string.

Similar Posts