in reply to Re: Replacing numbers with links
in thread Replacing numbers with links
you need to escape the '/' in <\/a>, since it would improperly terminate the regex otherwise.
or use something other than a forward slash as your regex delimiter, for example paired curly brackets like this
$mystring =~ s{(\d{3,5})} {<b><a href='lookup.cgi?id=$1</a>}g;
You often see matching against *nix paths using the default forward slash delimiter (and omitting the m as it is not required with / ... /) when using a different delimiter would be more readable.
if( $path =~ /\/path\/to\/file/ ) { ... }
is, I feel, much harder to read than
if( $path =~ m{/path/to/file} ) { ... }
Cheers,
JohnGG
|
|---|