I'm trying to find every 10 digit series of numbers within a larger series of numbers using re in Python 2.6.
I'm easily able to grab no overlapping matches, but I want every match in the number series. Eg.
in "123456789123456789"
I should get the following list:
[1234567891,2345678912,3456789123,4567891234,5678912345,6789123456,7891234567,8912345678,9123456789]
I've found references to a "lookahead", but the examples I've seen only show pairs of numbers rather than larger groupings and I haven't been able to convert them beyond the two digits.
(a|ab|abc)can generally be rewritten as non-overlapping ones with nested capture-groups, e.g.(a(b(c)?)?)?, where we ignore all but the outermost (i.e. leftmost) capture group when unpacking a match; admittedly this is slightly painful and less legible. This will also be a more performant regex to match. - smci