0

So I want to add something to my whitelist such that what ever begins with the prefix a and does not continue with b should be blocked.

Example:

a.b.blah -> Good
a.c.blah -> Bad, should be blocked

I am not sure as how to go about writing that particular regex. Any pointers?

noMAD
  • 7,744
  • 19
  • 56
  • 94

1 Answers1

0

Say you have the string "a b", you can use /a(?= *b)/. Note that the space is in (?= ) so that it's not returned as part of the match. That will see if it follows.

If you don't want it to follow, use /a(?! *b)/.

Sly
  • 1,145
  • 7
  • 19