I want to match the following:
any string which contains any character, except / or . this is done using ([^/\.]+), how ever, I also want to add a string “faq” so to match any character, except if it’s a string of “faq”, some examples:
Currently, my Regex:
^([^/\.]+)/([^/\.]+)/$
However, it captures “faq” aswell.
faq/fsdfsd/ => No match
faqgff/fdsfs/ => Match
jhpo/ijkd/ => Match
f/iout/ => Match
a/iout/ => Match
q/iout/ => Match
I’ve tried running ([^/.]+)
Yes, it’s for .htaccess redirects 🙂
This would be a negative lookhead
it is true when it does not find the pattern “faq”
So include it in your regex like this
Then it will match for your pattern, but fail if the string includes “faq”. (Hope I understood you correctly)
See it here on Regexr