Jonathan Dawson
Jonathan Dawson

Reputation: 3

Regex that matches string that starts with but does NOT include

I'm trying to build a Regex that matches any string that starts with "form submit success mail" but does not contain the digits 306

Here's what I've got so far: /^(?i)(form submit success mail(?!/(306))).*/gm

3 example strings:

form submit success mail - 306 - how are you today
form submit success mail - 2019 - this is a test
form submit success mail - 675 - what the

The query should match the bottom 2 strings but not the first.

Tested in https://regex101.com/ but doesn't seem to work - any help appreciated.

Upvotes: 0

Views: 196

Answers (1)

Keith Nicholas
Keith Nicholas

Reputation: 44316

you can go with something like

^form submit success mail(?!.*306).*$

Upvotes: 0

Related Questions