Sometimes we want to see if something is followed by something else without actually including the second part.
That’s where lookaheads and lookbehinds come in.
(?=)
- Positive lookahead
(?!)
- Negative lookahead
(?<=)
- Positive lookbehind
(?<!)
- Negative lookbehind
What you’re looking for goes inside the parentheses.
For example:
\w+(?=\.pdf) - matches any word followed by .pdf (excluding the .pdf)
Sadly, not all browsers support lookbehinds, so we will focus on lookaheads for now
Match only the prices, excluding the €