[HRPM] quick question

chicks at chicks.net chicks at chicks.net
Tue Nov 14 12:30:20 CST 2000


On Mon, 13 Nov 2000, Troy E. Webster wrote:
> I need some regular expression help again.

I want a panel van with a big red "/?/" for regular expression emergency
assistance.  :-)

> I'm trying to match something that should (I thought) be pretty easy.  
> It's actually versioning info that I want to get rid of. For example,
> the line could look like:
> 
> 1.1.1.2
> <or>
> 1.1.1
> <or>
> .1.1.1.1.1.1.1.1.2
> <etc>
> 
> so I tried $_ =~ /(\.*)((\d)(\.)(\d))+/
> 
> ... and a huge number of other permutations with the parenthesis.
> 
> And I don't want to match money i decimal form ($1.25).
> 
> Any help would be appreciated.

This is what I came up with:

#!/usr/bin/perl -w

@input = qw( $1.25 1.1.1.2 1.1.1 .1.1.1.1.1.1.1.1.2 );

foreach $in (@input) {
        $save = $in;

        $in =~ s/\d*(\.\d+){2,}//;

        print "'$save' turned into '$in'\n";

}

-- 
</chris>

"Pinky, you've left the lens cap of your mind on again." - The Brain





More information about the Norfolk-pm mailing list