Lasso Soft Inc. > Home

[validip_9]

Linkvalidip_9
AuthorJolle Carlestam
CategoryComparator
Version9.x
LicensePublic Domain
Posted07 Nov 2010
Updated07 Nov 2010
More by this author...

Description

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

Sample 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

Source Code

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.

<!--?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
 
 
?>

Related Tags

Comments

No comments

Please log in to comment

Subscribe to the LassoTalk mail list

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft