Reputation: 1980
I'm developing a dynamic controller which accept this urls:
Note: reviewer_test2 is excluded
I'm having a hard time figuring it out. This is what I don't so far:
^(mock|reviewer)_test[1-5]$
I also don't know how do I interpret 3.1
and 3.2
Upvotes: 1
Views: 102
Reputation: 16060
As you can see at this link: http://regexr.com?37dtn
^(mock_test[1-5])|reviewer_test([145]|3\.1|3\.2)$
^ = start a line with
(mock_test[1-5]) = the string 'mock_test' followed by a number from 1 to 5
I think the '(' and ')' are not necessary
| = OR
reviewer_test = the string 'reviewer_test'
([145]|3\.1|3\.2) = the numbers 1,4,5 OR the number 3.1 OR the number 3.2
$ = end of line
If it is a limited number I wouldn't use a regex, because it seems to be some kind of write once read never again
code.
Upvotes: 0
Reputation: 43673
^(?:mock_test[1-5]|reviewer_test(?:[145]|3[.][12]))$
^(?:mock_test(?:1|2|3|4|5)|reviewer_test(?:(?:1|4|5)|3\.(?:1|2)))$
Upvotes: 5