-4

I want to create a regex pattern to allow all the string with: gallery-a

or strings which start with gallery-a than a white space and after each string is accepted except clip-a.

Examples:

gallery-a ACCEPTED
gallery-a kfjrgrgl elrgkelk ACCEPTED
gallery-a clip-a NOT ACCEPTED

I tried with ^gallery-a((?!clip-a).)*$ but it doesn't work.

Jan
  • 42,290
  • 8
  • 54
  • 79
  • Duplicate of [Regex: match everything but specific pattern](https://stackoverflow.com/questions/1687620/regex-match-everything-but-specific-pattern), [Regular expression to match a line that doesn't contain a word](https://stackoverflow.com/q/406230/8967612). – 41686d6564 stands w. Palestine Aug 14 '20 at 11:46

1 Answers1

1

You can use

^gallery-a(?!.*clip-a).*

See a demo on regex101.com.

Jan
  • 42,290
  • 8
  • 54
  • 79