Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Strip leading zeros
Message
From
22/10/2009 15:55:08
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 8 SP1
Miscellaneous
Thread ID:
01430254
Message ID:
01430780
Views:
68
Thanks again. I think either I didn't explain what I need properly or this won't work. Using the same c_test cursor I tried
SELECT c_test.ID FROM c_test WHERE loRegEx.Replace(c_test.ID, '$1') = '2' 
&& only record 4 returned and should have been all 4 records

SELECT c_test.ID FROM c_test WHERE loRegEx.Replace(c_test.ID, '$1') = '26'  
&& nothing returned. and should have been record 3
I do appreciate the help.

>>Thanks for showing me this. I've never worked with regular expressions. Is there any way to incorporate it into a SELECT WHERE or SET FILTER TO statement?
>
>Sure you can use it, speed might be an issue thou.
>
>
>clear
>LOCAL laTest(4), i
>
>CREATE CURSOR c_test (ID C(10))
>
>laTest[1]	= "0002567890"
>laTest[2]	= "0000027890"
>laTest[3]	= "00002678-1"
>laTest[4]	= "0000000002"
>
>FOR i = 1 TO ALEN(laTest, 1)
>	INSERT INTO c_test values (laTest[i])
>NEXT i
>
>loRegEx			= Createobject('VBScript.RegExp')
>
>with loRegEx as VBScript.RegExp
>	.Pattern		= '^0+(.*)'
>	.IgnoreCase		= .T.
>	.Global			= .T.
>ENDWITH
>
>SELECT CAST(loRegEx.Replace(c_test.ID, '$1') as C(10)) as ID FROM c_test ORDER BY 1
>
>SELECT c_test
>
>BROWSE FOR loRegEx.Replace(c_test.ID, '$1') = '27890'
>
>SET ANSI on
>SELECT c_test.ID FROM c_test WHERE loRegEx.Replace(c_test.ID, '$1') = '27890'
>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform