Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Regular Expression help...
Message
De
28/01/2010 12:13:53
 
 
À
28/01/2010 11:57:16
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
Database:
Visual FoxPro
Divers
Thread ID:
01446344
Message ID:
01446352
Vues:
54
>>I must confess I have NEVER used a Regular Expression in my whole coding career. But I think I have a case to use it here...
>>
>>I want to know if a string matches this pattern: Word.Word (or, more specifically: "ValidTableName.ValidFieldName" )
>>
>>My goal is to test a string as being a valid "Table.Field" reference. It doesn't matter if the table or field exists or are open (and they may not be open), just that they are valid to be used as such in the VFP language syntax.
>>
>>So, the genereic pattern is "a word" [the dot character] "a word"
>>
>>But to be 100% percent safe, we must gauard against invalud TableName and FieldName characters...
>>
>>So, the specific test seems to be:
>>
>>Any single word that is would be a valid Table name
>>
>>Then the dot character "."
>>
>>Then another single word that is a valid Field name
>>
>>
>>Perhaps there are other or better ways to accomplish this, give a passed-in string.
>
>
>This should work
>
>	local obj
>	
>	obj = createobject('VBScript.RegExp')
>	obj.Global = false
>	obj.IgnoreCase = false
>	
>	obj.Pattern = '^[_a-zA-Z][\w]*\.[_a-zA-Z][\w]*$'
>	
>	?obj.Test('Table123name.f')
>
Thanks... This seems to work with my first few tests.

Man, I've got to study what all that does, but for now, problem appears to be solved.

I love UT.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform