3

I would like to return the entire string if it starts with page but not pager. I tried the example below but it does not work for me.

Example of a single-pass regex that contains alpha but does not contain beta (found on this post):

^((?!beta).)*alpha((?!beta).)*$

However if you try page but not pager this does not work:

^((?!pager).)*page((?!pager).)*$
Community
  • 1
  • 1
user610064
  • 481
  • 2
  • 11
  • 25

2 Answers2

3

This will do it:

^(?!pager)page.*$

or:

^page(?!r).*$

Both will allow 'pager' to be in the string, but not at the start.

Otiel
  • 18,404
  • 16
  • 78
  • 126
0

This will do:

^page(?:[^r].*)?$

      

spender
  • 117,338
  • 33
  • 229
  • 351