I'm trying to make a regex that matches with a text like /es/whathever1/whathever2/whatever3
and not ends with html
I tried with :
\/es\/.*[aA-zZ\-\_]\/.*[aA-zZ\-\_]\/.*[aA-zZ\-\_].*[.]html$.*$
but only matches if ends with .html
I'm trying to make a regex that matches with a text like /es/whathever1/whathever2/whatever3
and not ends with html
I tried with :
\/es\/.*[aA-zZ\-\_]\/.*[aA-zZ\-\_]\/.*[aA-zZ\-\_].*[.]html$.*$
but only matches if ends with .html
Using the character class [aA-zZ\-\_]
matches a single character of one of the listed. It is not the same as [a-zA-Z]
as A-z matches more characters.
You can repeat 3 times matching /
and 1+ word characters using a quantifier and add anchors for the start ^
and end $
of the string to prevent a partial match
^\/es(?:\/[\w-]+){3}$
See a regex demo