in reply to Re: classifying data
in thread classifying data

This could help you get started:

use warnings; use strict; while (<DATA>) { chomp; my $data = $_; print "$data: "; my $result = ($data =~ /^[+\-]?\$?[0-9.]+$/) ? "numeric" : "non-numeric"; print "$result\n"; } __DATA__ 1020 $10.21 -1023 +1.024 beer 10$25 -$102.6 A1027 1028$ $ $-1.029

BTW, watch out for those asterisk opertors in your patters. You used \d*, and the '*' could legitimately match '', since it does match a digit zero or more times! That pesky asterisk operator can lead to 'zero-width' matches, which can drive you nuts when you are starting with regular expresssions.

Hanlon's Razor - "Never attribute to malice that which can be adequately explained by stupidity"

Replies are listed 'Best First'.
Re: classifying data
by Abigail-II (Bishop) on Jan 19, 2004 at 16:50 UTC
    Your regexp will not match 900,000, but it will match .....

    Abigail

      Upon reflection, I think that your plan of using RegExp::Common is superior.

      Hanlon's Razor - "Never attribute to malice that which can be adequately explained by stupidity"