Regex Match Any Number Of Digits

Find the data you need here

We provide programming data of 20 most popular languages, hope to help you!

Previous PostNext Post

How to select any number of digits with regex?

http://www.website.com/directory/9892639512/alphanum3r1c/some-more-text-here/0892735235
directory\/([0-9]{7})\/
directory\/([0-9]+)\/
For matching an integer number of one single char/digit, specify:
[0-9]
But for matching any number of more than one char/digit; add "+":
[0-9]+
Example for matching hour with minutes of HH:MM format in a file:
grep "[0-9]\+\:[0-9]\+" file.txt
For matching an integer number of one single char/digit, specify:
[0-9]
But for matching any number of more than one char/digit; add "+":
[0-9]+
Example for matching hour with minutes of HH:MM format in a file:
grep "[0-9]\+\:[0-9]\+" file.txt
For matching an integer number of one single char/digit, specify:
[0-9]
But for matching any number of more than one char/digit; add "+":
[0-9]+
Example for matching hour with minutes of HH:MM format in a file:
grep "[0-9]\+\:[0-9]\+" file.txt
const match = 'some/path/123'.match(/\/(\d+)/)
const id = match[1] // '123'
//([\s\S]*?) matches any character including newline
var result = str.match(/<script>([\s\S]*?)<\/script>/g)
const regex = /([a-z]*)ball/g;
const str = "basketball football baseball";
let result;
while((result = regex.exec(str)) !== null) {
	console.log(result[1]); 
    // => basket
    // => foot
    // => base
}
/(.*)/
/(.*)/
[3-7] will match a single digit in the range 3 to 7.
\d\d       will match 2 consecutive digits
\d+        will match 1 or more consecutive digits
\d*        will match 0 or more consecutive digits
\d{3}      will match 3 consecutive digits
\d{3,6}    will match 3 to 6 consecutive digits
\d{3,}     will match 3 or more consecutive digits
[3-7][3-7]    will match 2 consecutive digits that are in the range 3 to 7
[3-7]+        will match 1 or more consecutive digits that are in the range 3 to 7
[3-7]*        will match 0 or more consecutive digits that are in the range 3 to 7
[3-7]{3}      will match 3 consecutive digits that are in the range 3 to 7
[3-7]{3,6}    will match 3 to 6 consecutive digits that are in the range 3 to 7
[3-7]{3,}     will match 3 or more consecutive digits that are in the range 3 to 7
[13579]       will only match "odd" digits
[02468]       will only match "even" digits
1|3|5|7|9     another way of matching "odd" digits - the | symbol means OR
\d|10        matches 0 to 10    single digit OR 10.  The | symbol means OR
[1-9]|10     matches 1 to 10    digit in range 1 to 9 OR 10
[1-9]|1[0-5] matches 1 to 15    digit in range 1 to 9 OR 1 followed by digit 1 to 5
\d{1,2}|100  matches 0 to 100   one to two digits OR 100
\d*0         matches any number that divides by 10  - any number ending in 0
\d*00        matches any number that divides by 100 - any number ending in 00
\d*[05]      matches any number that divides by 5   - any number ending in 0 or 5
\d*[02468]   matches any number that divides by 2   - any number ending in 0,2,4,6 or 8
[048]|\d*(00|04|08|12|16|20|24|28|32|36|40|44|48|52|56|60|64|68|72|76|80|84|88|92|96)
[048]|\d*([02468][048]|[13579][26])    - numbers divisible by 4
7|14|21|28|35|42|49

or you could do it this way

7|14|2[18]|35|4[29]

Previous PostNext Post

Related code examples