Ian Jones Logo

Regex

Positive/negative lookbehind

Match a pattern only if the pattern before the current pattern is met:

/(?<=a)b/

This will match b only if a is behind it.

/(?<!a)b/

In a similar sence, you can add a ! for a negative look behind. This will match anything that doesnt have an a before a b.

/(.*?):(?<=:.*?:)(.*)/

Resources