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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
<?Lasso
/**!
string -> validip
Extending the string type with a check to see if a string is a valid ip address. Will return true or false. Made after a request from Chris Wik
Regular expression found here:
http://www.regular-expressions.info/examples.html
2010-11-08 Jolle Carlestam First version
Usage:
var(testips = array(
'192.168.2.55', // valid
'255.255.255.255', // valid
'0.0.0.0', // valid
'198.5.kk.25', // not valid
'198.5.4', // not valid
'999.999.255.255', // not valid
'my mother likes cakes' // not valid
))
var(output = array)
with i in $testips
do => {
$output -> insert(string(#i) -> validip )
}
$output
Lasso 9 -> array(true, true, true, false, false, false, false)
**/
define string -> validip() => ((regexp(-find = `\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b`, -input = self, -ignorecase)) -> findall) -> size == 1
/**!
jina_validip(string)
A method that checks if a string is a valid ip address. Will return true or false. Made after a request from Chris Wik
2010-11-08 Jolle Carlestam First version
Usage:
var(testips = array(
'192.168.2.55', // valid
'255.255.255.255', // valid
'0.0.0.0', // valid
'198.5.kk.25', // not valid
'198.5.4', // not valid
'999.999.255.255', // not valid
'my mother likes cakes' // not valid
))
var(output = array)
with i in $testips
do => {
$output -> insert(jina_validip(#i) )
}
$output
Lasso 9 -> array(true, true, true, false, false, false, false)
**/
define string_validip(input::string) => #input -> validip
?>
|