|Keep It Simple, Stupid|
Replacing numbers with linksby danambroseUK (Beadle)
|on Jul 16, 2006 at 14:18 UTC||Need Help??|
danambroseUK has asked for the
wisdom of the Perl Monks concerning the following question:
I have unstructured strings which contain ID reference numbers inline. A reference number is made up of between 3-5 digits i.e 200, 50210, 121, 3222 etc.
What I would like to do is change all of the numbers into hyperlinks; to the URL lookup.cgi?id=XXXXX.
I tried doing a match to extract the numbers, then a substitution to replace - this works fine, except that as the URL also contains a number of 3-5digits in length, this screws the substitution.
Any ideas? Maybe a solution that does the match, and substitution in one go?
Thanks in advance