re.findall(r'\b[0-9]{2,7}-[0-9]{2}-[0-9]{2}\b', txt)

\b         - a word boundary.
[0-9]{2,7} - 2 to 7 digits
-          - a hyphen-minus
[0-9]{2}   - exactly 2 digits
-          - a hyphen-minus
[0-9]{2}   - exactly 2 digits
\b         - a word boundary.

Seems quite straightforward to me. I'll be impressed if you can write
that in Python in a way which is easier to read.


Now that I know what {} does, you're right, that IS straightforward! Maybe 2023 will be the year I finally get off my arse and learn regex.

Thanks :)

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to