Does Regex match a specific group of digits of a certain length?

I found this: Regex to match digits of a certain length , but it talks about Python. I want to be able to get a group of random numbers of a certain length. Therefore, if I have it 167691#15316243, it will correspond 15316243. I am not sure how to implement this. right now I have new RegExp('[0-9]+', "g");one that perfectly matches a group of numbers, but now I realized that I will have several times when I will have more than one group, and I only need a group of eight numbers.

+5
source share
3 answers

You can specify the length of the match set using {}.

For instance: [0-9]{8}

0 9 8 .

/, legnth. , 4 8, : [0-9]{4,8}

+10
[0-9]+ - Matches one or more numbers
[0-9]{8} - Matches exactly 8 numbers.
[0-9]{8,10} - Matches between 8 and 10 numbers.
[0-9]{8,} - Matches 8 or more numbers.
[0-9]* - Matches zero or more numbers.
[0-9]? - Matches zero or one number.
+14

:

"167691#15316243".match(/\d{8}/g);

: http://jsfiddle.net/3r5vd/


( ).

:

[...] , , . {min,max}, min - , , max - , , min, . , max , . , {0,} *, {1,} +.
, max min .

+2

All Articles