Francesco G.
Francesco G.

Reputation: 717

Javascript regex match doesn't contain keyword

I would like to match a string that not start with keyword "side" (case sensitive)...

I have tried like this: /^(?!side).*$/i but don't work for me because I would like to accept for example: "side1", "side 1"

I hope I was clear

Edited:

Bye

Upvotes: 0

Views: 60

Answers (2)

Dalorzo
Dalorzo

Reputation: 20014

OK I would to take a leap of faith here...

(?!^side$)\b.+\b

Online Demo

Upvotes: 0

anubhava
anubhava

Reputation: 784958

You can use this negative regex with word boundary:

/^(?!side$)/i

Upvotes: 1

Related Questions