regex url validator?

Bob Sneidar bobsneidar at iotecdigital.com
Tue Oct 23 10:56:11 EDT 2018


I mean AN other function: rsIsValidEmail_LC

Bob S


> On Oct 23, 2018, at 07:54 , Bob Sneidar via use-livecode <use-livecode at lists.runrev.com> wrote:
> 
> This looks like it is dependent on other functions. Are these built into Livecode??
> 
> Bob S
> 
> 
>> On Oct 23, 2018, at 06:26 , Stephen MacLean via use-livecode <use-livecode at lists.runrev.com> wrote:
>> 
>> Hi Tom,
>> 
>> Don’t know if you found a solution yet, but this is from the rsIsValid suite I put together a few years back.
>> 
>> http://forums.livecode.com/viewtopic.php?f=16&t=26653&p=138698#p138698 <http://forums.livecode.com/viewtopic.php?f=16&t=26653&p=138698#p138698>. 
>> https://github.com/renegadesteve/rsIsValid <https://github.com/renegadesteve/rsIsValid>
>> 
>> 
>> Below is the LCS version:
>> function rsIsValidURL pURL
>> 
>> put pURL into tCC
>> 
>> // get scheme
>> 
>> put "^(?<scheme>[a-z][a-z0-9+\-.]*):" into tSchemeRegex
>> 
>> get matchText(tCC, tSchemeRegex,tScheme)
>> 
>> // check scheme for http, https, ftp, ftps, mailto, nntp, news, or file
>> 
>> if it <> true then return false
>> 
>> if tScheme = "mailto" then
>> 
>> //get the email address from the URL and then validate it
>> 
>> delete char 1 to 7 of tCC
>> 
>> return rsIsValidEmail_LC(tCC)
>> 
>> else
>> 
>> // setup the regex pattern
>> 
>> put "^(?:http://|https://|ftp://|ftps://|nntp://|news://)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\x{00a1}-\x{ffff}0-9]-*)*[a-z\x{00a1}-\x{ffff}0-9]+)(?:\.(?:[a-z\x{00a1}-\x{ffff}0-9]-*)*[a-z\x{00a1}-\x{ffff}0-9]+)*(?:\.(?:[a-z\x{00a1}-\x{ffff}]{2,}))\.?)(?::\d{2,5})?(?:[/?#]\S*)?$" into tURLRegex
>> 
>> // run filter against regex pattern and set result to true if it matches.
>> 
>> filter tCC with regex pattern tURLRegex into tMatch
>> 
>> if tMatch <> empty then
>> 
>> return true
>> 
>> else
>> 
>> return false
>> 
>> end if
>> 
>> end if
>> 
>> end rsIsValidURL
>> 
>> 
>> Best,
>> 
>> Steve MacLean
>> 
>>> On Oct 22, 2018, at 10:07 PM, Tom Glod via use-livecode <use-livecode at lists.runrev.com> wrote:
>>> 
>>> Hi peeps,
>>> 
>>> I'm trying to use regex to validate a list of URLs
>>> 
>>> I've tried 4 or 5 different "regular" expressions that supposedly work
>>> ..... but LC does not give me anything back.  None of them work,
>>> 
>>> Like for example ... this one.
>>> 
>>> ^(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+$
>>> 
>>> or this one
>>> 
>>> /^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/
>>> 
>>> or this one just to make sure
>>> 
>>> (https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)
>>> 
>>> Does anyone know how to get these or others to work in LC?
>>> 
>>> Thanks,
>>> 
>>> Tom
>>> _______________________________________________
>>> use-livecode mailing list
>>> use-livecode at lists.runrev.com
>>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>> 
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode



More information about the use-livecode mailing list