[oclug] A Friday Regex Head Scratcher
Jon Earle
je_oclug at kronos.honk.org
Fri Apr 17 14:38:04 EDT 2009
Hey folks,
Probably simple, but the answer is eluding me at the moment. I have a block
of text that contains:
some text PR 1234 more text
and I want to convert the number to a link to the issue in the bug reporting
database. This is no problem, there is a regex to do just that:
(\b(PR|SCR)[:s#]?\s?) # PR or SCR followed by :|s|#|whitespace
(\s[a-z0-9-]+\/)? # a category name & a slash (optional)
([0-9]+) # the PR number
and that works perfectly. Now, suppose that the block of text contains:
some text PR 1234, 5678 ,2345 more text
How would I need to adjust the regex to account for the unknown number of
additional comma-number sequences so that they can each be htmlified?
I need to inject this into both perl and python code.
Thanks for any thoughts!
Jon
More information about the OCLUG
mailing list