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

Thank you so much for this. It works! This still tags 4-digit numbers as part of a phone number, but that's okay. I'd love to hire you for several projects as I'm just a hack.

Replies are listed 'Best First'.
Re^3: Detecting numbers continued
by aaron_baugher (Curate) on Apr 24, 2015 at 02:33 UTC

    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.

Re^3: Detecting numbers continued
by AnomalousMonk (Archbishop) on Apr 24, 2015 at 03:32 UTC

    You're very welcome. I'm not in the job market right now. Have you tried Perl Jobs?

    Another alternative is this site, where you can often find copious help for free! As aaron_baugher has alluded, several approaches to the phone number exclusion problem have already been given in answers to your previous posts. To get the most out of this site, you must be willing to give useable input and output data in addition to clear descriptions of your problem and, one hopes, your efforts at a solution. I.e., you must help us to help you.


    Give a man a fish:  <%-(-(-(-<