Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Regular Expression help...
Message
From
28/01/2010 12:34:40
 
 
To
28/01/2010 11:57:16
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01446344
Message ID:
01446357
Views:
43
>>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')
>
Could you help me EXTRACT the FIRST [TableName.Field] occurrence from a passed in string...


For instance, I may pass in:

"(iif(seek(csrQuoteMtlItems.vendor, [Vendor], [vendno]), Vendor.company, []))"

And I need to extract the "csrQuoteMtlItems.vendor" part.


Note: the "(iif(seek(" beginning part is not constant and could vary, but the TableName.FieldName pattern would pretty much always be in there somewhere. The actual Table and Field name would also vary.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform