-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathf6_regex.pl
42 lines (36 loc) · 1.38 KB
/
f6_regex.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/perl -w
use strict;
sub IsNumeric{
if(@_ != 1){
printf("Num. parametros errados ");
return 0;
}
#print("OK");
if($_[0] =~ m/^[\+|\-|\d]?\d*\.?\d+$/){ # verifica numéricos válidos.
return 1;
}else{
return 0;
}
}
#printf ("%d\n", IsNumeric() ); # erro 0
#printf ("%d\n", IsNumeric("1") ); # OK 1
#printf ("%d\n", IsNumeric("1", "2") ); # erro 0
printf("%6s -> %d\n", "", IsNumeric("")); # 0
printf("%6s -> %d\n", " ", IsNumeric(" ")); # 0
printf("%6s -> %d\n", "+", IsNumeric("+")); # 0
printf("%6s -> %d\n", "-", IsNumeric("-")); # 0
printf("%6s -> %d\n", "30", IsNumeric("30")); # 1
printf("%6s -> %d\n", "1", IsNumeric("1")); # 1
printf("%6s -> %d\n", "0", IsNumeric("0")); # 1
printf("%6s -> %d\n", "-1", IsNumeric("-1")); # 1
printf("%6s -> %d\n", "-10", IsNumeric("-10")); # 1
printf("%6s -> %d\n", "+1", IsNumeric("+1")); # 1
printf("%6s -> %d\n", "+100", IsNumeric("+100")); # 1
printf("%6s -> %d\n", "+100.", IsNumeric("+100.")); # 0
printf("%6s -> %d\n", "0.1", IsNumeric("0.1")); # 1
printf("%6s -> %d\n", ".1", IsNumeric(".1")); # 1
printf("%6s -> %d\n", "-0.1", IsNumeric("-0.1")); # 1
printf("%6s -> %d\n", "-100.", IsNumeric(".1")); # 0
printf("%6s -> %d\n", ".0.1", IsNumeric(".0.1")); # 0
printf("%6s -> %d\n", "H1.", IsNumeric("H1.")); # 0
printf("%6s -> %d\n", " 10", IsNumeric(" 10")); # 1