in reply to Replacing numbers with links
What I think you want to do is replace all of the number strings in a single, global regular expression substitute.
You could do this with, for example:
$mystring =~ s/(\d{3,5})/<b><a href='lookup.cgi?id=$1<\/a>/g;
Several things to note: 1) you can change the \d{3,5} if it turns out you have numeric strings which are less than 3 or greater than 5 digits. 2) you need to escape the '/' in <\/a>, since it would improperly terminate the regex otherwise. 3) the expression $1 is a backreference, used to specify the thing that was matched.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Replacing numbers with links
by johngg (Canon) on Jul 16, 2006 at 15:36 UTC | |
|
Re^2: Replacing numbers with links
by GrandFather (Saint) on Jul 16, 2006 at 17:59 UTC | |
|
Re^2: Replacing numbers with links
by Anonymous Monk on Jul 16, 2006 at 18:03 UTC |