in reply to Regular Expression Fun

Try:

push @ten_digit_numbers, $1 while ($string =~ /(\d{10})/g); print "found: @ten_digit_numbers\n";

Replies are listed 'Best First'.
Re: Re: Regular Expression Fun
by dvergin (Monsignor) on Feb 26, 2002 at 20:31 UTC
    The "push ... while" is not needed:
    my $string = "this 12345567890 is a 1029384756 test"; my @results = $string =~ /\d{10}/g; print "@results\n";
Re: Re: Regular Expression Fun
by dragonchild (Archbishop) on Feb 26, 2002 at 20:08 UTC
    In other words, instead of trying to remove stuff, flip it around and try to get stuff. If all you want is the 10-digit numbers, zenfargoyle's answer is the appropriate one.

    ------
    We are the carpenters and bricklayers of the Information Age.

    Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.