Draxy Draxy - 2 months ago 7
Javascript Question

regEx for a range of 8600000–9999999?

I'm looking for a way to validate a phone number with the length of 7, and within the rage of 8600000–9999999 (This is a region in New Zealand, witch is why google was no help as no one talks about New Zealand -- ever). Does anyone know a regEx that can do this?

I'm new to JS, but I think that a Regular Expression would be the best way to do this. (If not let me know.)

Note: The input data type of the phone number is text. (I know I can use number but I ran into bugs with it.)

EDIT -- no lines / separation, just numbers. (Also very fast answers just wow)

Thanks in advance !

Answer

This one's actually pretty easy:

/8[6-9][0-9]{5}|9[0-9]{6}/

As long as you don't need separators, anyways.

Comments