The library's fines book: a lookbehind checks for Rp before a number without taking it. What is checked, taken and refused is marked on the board, from the…
Why it matters
Lookbehind and lookahead come up whenever you need context but do not want to carry it: the number after Rp without the Rp, a price before its unit, a find-and-replace that only applies between certain patterns. Without them, you capture and then throw the piece away yourself.
The key idea
An assertion is zero-width: it checks a neighbour without taking it
Try it in this playground
Use a lookbehind (?<=…) The dashed outline shows what was checked: it must be there, but it is not in the result.
Watch (?<!…) say no The × on the board: the number matched, the assertion refused. Watch what happens one step on.
Use a lookahead(?=…) and (?!…) check to the right, after what is taken.
Write your own parts Say take \w+ after a #, or a number before %.