Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
URL validation
Message
 
 
À
26/01/2016 13:01:38
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01630233
Message ID:
01630262
Vues:
52
The pattern doesn't seem correct as I tried all sorts of URLs including

https://social.msdn.microsoft.com

and all returned invalid.


I tried a different pattern (from http://stackoverflow.com/questions/161738/what-is-the-best-regular-expression-to-check-if-a-string-is-a-valid-url) first answer and it seems to work.

>>Hi everybody,
>>
>>I have a textbox which will allow to enter a valid URL (https or http). Do you know what code should I use for validation of the user's input?
>>
>>Thanks in advance.
>
>
Function ValidUrl
>Lparameters tcUrl
>Local lcFilter As String, ;
>   llReturn As Boolean, ;
>   loRegex As Object
>If Pcount() > 0 And Vartype(lcMail) = [C]
>   Text To m.lcFilter Noshow Pretext 15
>         ^(http(?:s)?\:\/\/[a-zA-Z0-9\-]+(?:\.[a-zA-Z0-9\-]+)*\.[a-zA-Z]{2,6}
>         (?:\/?|(?:\/[\w\-]+)*)(?:\/?|\/\w+\.[a-zA-Z]{2,4}
>         (?:\?[\w]+\=[\w\-]+)?)?(?:\&[\w]+\=[\w\-]+)*)$
>   Endtext
>   m.loRegex = Createobject([VBScript.RegExp])
>   m.loRegex.Pattern = m.lcFilter
>   m.loRegex.IgnoreCase = .T.
>   m.loRegex.Global = .F.
>   m.llReturn = m.loRegex.Test(m.tcUrl)
>   m.loRegex = .Null.
>   Release m.loRegex
>Endif
>Return m.llReturn
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform