0

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:

  • Expression cannot contain only the word "side" with any given case.
  • If the expression has the word side it must be accompanied by something else meaning more characters.

Bye

5
  • 4
    In what sense does "side 1" not start with the keyword "side"? Commented Oct 26, 2015 at 14:10
  • yes... but for me is only wrog "side", "Side", "SIDE", "sIdE". All the other it's ok Commented Oct 26, 2015 at 14:19
  • @FrancescoG. what you are saying is that "Side" is incorrect but "Side something else" is correct Commented Oct 26, 2015 at 14:21
  • OK, one more time: how does "side 1" not start with "side"? (Note that it does start with "side".) Commented Oct 26, 2015 at 14:21
  • Yes @Dalorozo... "Sidesomething else" is correct too Commented Oct 26, 2015 at 14:25

2 Answers 2

1

You can use this negative regex with word boundary:

/^(?!side$)/i
Sign up to request clarification or add additional context in comments.

8 Comments

this does not seem to be the answer of unclear question
It's ok for "side1", but no for "side 1"
still it is not matching anything just avoid to match side
What do you mean by not matching anything? Check this regex There are 2 matches
what is the matching pattern of your expression above? There is only a Negative Lookahead but nothing else
|
0

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

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

Online Demo

2 Comments

Now this regex is same as my answer :)
yesss... thank so much to everybody! For me regex is arabic

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.