in reply to Re: A function to determine if a string is numeric
in thread A function to determine if a string is numeric
use Regexp::Common; use Data::Dumper; use v5.30.0; my $value = "+a1.2cd"; if ( $RE{num}{int} -> matches($value) ) { say "INTEGER patern:\t".$RE{num}{int}; say $value; say "It is Integer"; }elsif ( $RE{num}{real}->matches($value) ) { say "REAL patern:\t".$RE{num}{real}; say $value; say "It is Real"; }else{ say "It is String"; }
I tried Regexp::Common , but seams to behave weird to me. The code above is saying :
It is Integer
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: A function to determine if a string is numeric
by Tux (Canon) on May 18, 2020 at 12:17 UTC | |
|
Re^3: A function to determine if a string is numeric
by hippo (Archbishop) on May 18, 2020 at 12:19 UTC |