
BillKSmith
Veteran
Jul 18, 2012, 4:33 AM
Post #2 of 5
(705 views)
|
|
Re: [gerble1000] if string is numeric and 11 digits long
[In reply to]
|
Can't Post
|
|
If you are sure that $string contains what you think, use a regular expression. But be warned, if perl changes the numeric string to a number, the leading 0 is lost.
use strict; use warnings; my @strings = ( '07232343576', '07569898665', '0946nd769', 'gciasu8neeeo', ); foreach my $string (@strings) { if ($string =~ /07\d{9}/) { print "valid: $string\n"; } else { print "invalid $string\n"; } } Good Luck, Bill
|