Good evening, I’m learning regular expressions to PHP. I am not managing to make 1 to 30 and 1 to 10. For 1 to 9, I thought [1-2-3-4-5-6-7-8-9] or [1-9]{1}, which is more correct? Thanks in advance 🙂
Share
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.
For 1 to 9, there is straight forward regex that is
[1-9].For 1 to 10, and 1 to 30, a combination of rules are to be applied.
For 1 to 10, you can use this:
For 1 to 30, this regex could be used:
or
the first part
30, would look for exact match i.e. 30.the second part
[12]\dor[12][0-9], would look for numbers between 10 to 29.the last part
[1-9]would look for numbers between 1-9.