> Sveiki,
>
> ar yra cia kas su regular expression dirbes?
>
> Reikia parasyti tel nr patikrinima
>
> • 2 – 20 digits
> • Only one instance of “+”, and the “+” (if exists) must be the
> first character
> • Only one instance of “-”, and if exists it must not be the first
> character
> • Only one instance of “/”and if exists it must not be the first
> character • No other characters allowed
>
perlu:
$nr = '+370-1258';
print "ok" if
($nr =~ /^(\+|\d)[\-\/0-9]+$/ &&
$nr =~ tr/\-/\-/ <= 1 &&
$nr =~ tr/\//\// <= 1 &&
$nr =~ tr/[0-9]/[0-9]/ >= 2 &&
$nr =~ tr/[0-9]/[0-9]/ <= 20);