| Link | validip_9 |
| Author | Jolle Carlestam |
| Category | Comparator |
| Version | 9.x |
| License | Public Domain |
| Posted | 07 Nov 2010 |
| Updated | 07 Nov 2010 |
| More by this author... | |
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
Also as a method string_validip. The method will call string -> validip
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
Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.
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
?>
No comments
©LassoSoft Inc 2015 | Web Development by Treefrog Inc | Privacy | Legal terms and Shipping | Contact LassoSoft