I was searching for regular expression for just 7 digits and another for just 9 digits, all I found was for [0-7] and [0-9], not exact 7 and 9 digits – no shorter no longer-
How can I find those ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Matching seven digits:
Matching nine digits:
If you want to match either seven or nine digits, use this:
or just this:
Quantifier: The number in curly braces is what we call the quantifier, it determines how many repetitions of the preceding pattern (character or group in parentheses) are matched.
Beginning and end of a string (or line) are denoted with the caret
^and dollar sign$respectively.The pipe character
|is used to provide two alternative patterns. It is important to know, that it’s precedence is lowest (thanks raina for reminding me), i.e. it will either match everything to its left or to its right, unless constrained with parentheses.