String to be matched: first-3-days
Regex: first-[3,6]-days
This Regex matches the string as expected. But, if there are any other characters before or after the given string, that will be an invalid match for me. For instance,
hellofirst-3-days – is invalid match
first-3daysfirst-3-days – is invalid match
Any hints please.
>Solution :
I guess you want to match 3 or 6 and not ,. If that is true, you should use [36] and not [3,6]
You can use word boundaries:
\bfirst-[36]-days\b
Or if your input string should start from first and end with days you can use start/end string specifiers, e.g.:
^first-[36]-days$