Reputation: 6480
I need to skip a query string when the first word is 'page'.
Currently I am using a string separated by slashes and use them as parameters of the query string like so:
^(.*)$ // string with 1 parameter
^(.*)/(.*)$ // string with 2 parameters
How would I skip matching entirely if the string contains the word 'page' before first or no slash?
This is what I'm trying to do but it still returns some values but skips the word.
((?![page]).*)
http://regex101.com/r/dA3jE7/1
Example:
word // match
some/word // match
word/somepage // match
page // do not match
page/word // do not match
Upvotes: 0
Views: 98
Reputation: 1840
An other way of doing it using negative look ahead.
^(?!page)(\w+\/?)+$
Upvotes: 1
Reputation: 70722
You want to remove the character class wrapped around your whole word.
^(?!page).*$
Upvotes: 2