in reply to Re^2: Detecting numbers continued
in thread Detecting numbers continued

I posted this solution in your previous thread, but maybe I was late and you missed it. It does the job while skipping phone numbers. If you don't understand any of it, just ask.

#!/usr/bin/env perl use 5.010; use strict; use warnings; my $text = <<END; Apt.302. 123-4567. 4021 207-555-1531 Apt. 987 END $text = " $text "; # pad it so my regex will work if a number # appears at the beginning or end of line $text =~ s|( # start capturing in $1 [^\d-] # any single character other than a digit or dash ) # end capture of $1 ( # start capturing in $2 \d\d\d # three digits in a row \d? # zero or one digits (for a total of 3-4) ) # end capture of $2 ( # start capture of $3 [^\d-] # any single character other than a digit or dash ) # end capture of $3 |$1<a href="\?unit=$2"><b>$2</b></a>$3|gx; # Replace captured # sections with HT +ML added $text = substr($text, 1,-1); # trim off padding say $text;

Aaron B.
Available for small or large Perl jobs and *nix system administration; see my home node.