What Regex do I need for match this url:
Match:
1234
1234/
1234/article-name
Don’t match:
1234absd
1234absd/article-name
1234/article.aspx
1234/any.dot.in.the.url
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.
You can try:
This matches a non-empty sequence of digits at the beginning of the string, followed by an optional suffix of a
/and a (possibly empty) sequence of word characters (letters, digits, underscore) and a-.This matches (see on rubular):
But not:
No parenthesis regex
You shouldn’t need to do this, but if you can’t use parenthesis at all, you can always expand to alternation: