Look-ahead and look-behind
Look-ahead and look-behind may be used to describe what happens around an expression, without affecting what is captured or what is replaced.
You can use positive look-ahead and look-behind to match strings that begin or end with specific values. And, you can use negative look-ahead and look-behind to match strings that do not begin or end with specific values:
Expression |
Description |
Matches |
Does not match |
|
Positive look-ahead |
one, two |
one, three |
|
Positive look-behind |
... |