Reputation: 19413
/news/article-title.html
is not being caught by the regex:
^/news/[^(archives)].+.html
?
I'm trying to have articles that do NOT have "archives" in the filename, but start with "/news/"
Thanks!
Upvotes: 1
Views: 111
Reputation: 137997
You should use a negative lookahead. Character classes only work for a single character. Also, don't forget to escape the dot.
If "archives" cannot be at the beginning:
^/news/(?!archives).+\.html
If "archives" cannot anywhere:
^/news/((?!archives).)+\.html
More tips:
archives
as a whole word: (?!archives\b).+
or (?!archives-).+
\.html
is at the end (it may appear more than once): \.html(?=$|[?&])
Upvotes: 6
Reputation: 17321
You can't use the not of a character block to not an entire string.
[^(archives)]
This is interpreted as a character that is not one of the following: (, a, r, c, h, i, v, e, s or ).
Upvotes: 1