Imagine I have the string abcdefghi
If I apply the regular expression
m/([a-z])([a-z])/g
to it, I get disjoint pairs
ab, cd, ef, gh.
What I want is all overlapping pairs ab, bc, cd, de, ef, fg, gh, hi.
When I use a lookahead, like
m/([a-z])(?=[a-z])/g
I get the first letter of each pair
a, b, c, d, e, f, g, h, but the lookahead per se is not kept.
How can I tell the regex engine that I want the first letter but also the lookahead, in order to obtain pairs of letters ab, bc, cd, de, ef, fg, gh, hi?