Seeker
Seeker

Reputation: 1927

Regex Unable to exclude a string

Here is my regex i want to exclude string login_overlay but i am unable to exclude that string from my regex it capture the login string and passes the regex:

(^\/$|!login_overlay|login|welcome|register|password_forgot|terms|privacy|company_site|account_calendar|account_cancel|account_facebook|account_google|account_ical|account_language|account_outlook|account_password)

What am i doing wrong is there something wrong with my regex condition?

Upvotes: 1

Views: 59

Answers (2)

Mark Reed
Mark Reed

Reputation: 95385

You can't exclude strings from regexes that easily. Although if your regex implementation supports negative lookahead, you can get close:

  (^\/$|(?!login_overlay|something_else_excluded|...)(login|welcome|...))

Upvotes: 2

anubhava
anubhava

Reputation: 786261

You need to use negative lookahead for that:

(?!.*?login_overlay)

See Lookaround Tutorial

Upvotes: 3

Related Questions