"Jeff Pang" schreef:
> guba:

>> how can I test if the nth (n=2) sign of a string is a number [0-9]?
> 
> Given you have this string: $str = "a9d0";
> you can check if the 2nd character is a number or not by:
>     my $c = substr($str,1,1);
>     print ($c=~/[0-9]/) ? "a number" : "not a number";

      my $n = 1;
      my $c = substr $str, $n, 1;
      print $c =~ /[0-9]/
            ? "a number"
            : "not a number"
      ;


Or use

      $str =~ m/\A.{1}[0-9]/

(where the {1} is there just for educational reasons :)

-- 
Affijn, Ruud

"Gewoon is een tijger."

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to