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') loRegEx.Pattern = '^0+2(.*)' SELECT c_test.ID FROM c_test WHERE loRegEx.Test(c_test.ID) && only record 4 returned and should have been all 4 records loRegEx.Pattern = '^0+26(.*)' SELECT c_test.ID FROM c_test WHERE loRegEx.Test(c_test.ID) && nothing returned. and should have been record 3Of course you can make the regular expression as complex as you want, lets say you want the ones that start with to 2 and end with 890, you simply do
loRegEx.Pattern = '^0+2(.*)(890)$' SELECT c_test.ID FROM c_test WHERE loRegEx.Test(c_test.ID)(well, not very complex, just to give you an idea)
>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>