M.R.
M.R.

Reputation: 4827

Regex to apply to everything except a folder

I'm trying to make a regular expression for an URL so that it affects everything except a certain folder. The regex will only apply to everything after the '/', so given an url the url http://www.blah.com/folder/main/file.html, it will apply only to folder/main/file.html - the regex expression I want is the expression that will basically match always when there is no 'folder/' in the url.

Upvotes: 1

Views: 605

Answers (1)

Petar Ivanov
Petar Ivanov

Reputation: 93030

You can use negative lookahead. For example this:

^(.(?!folder/))*$

will match anything which does not contain 'folder/'

Upvotes: 1

Related Questions