Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Quickly alltrim non-alpha chars from string
Message
From
03/08/2005 09:57:19
 
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9
Miscellaneous
Thread ID:
01037589
Message ID:
01038110
Views:
28
Hi Viv,

Thanks for the regex solution below. I'm familar with the VBScript.RegExp component, but never thought of using 2 seperate RegExp objects together. Great idea!

Cheers,

Malcolm

>This is a lot faster (but still doesn't beat Fox on short strings) :-)
>
>DEFINE CLASS Reg AS LINE
>  oRegExp1 = .NULL.
>  oRegExp2 = .NULL.
>  FUNCTION INIT()
>    WITH THIS
>      .oRegExp1 = CREATEOBJECT("VBScript.RegExp")
>      .oRegExp2 = CREATEOBJECT("VBScript.RegExp")
>      .oRegExp1.PATTERN = "^[^a-zA-Z]*"
>      .oRegExp2.PATTERN = "[^a-zA-Z]*$"
>    ENDWITH
>  ENDFUNC
>  FUNCTION NonAlphaTrim (cString)
>    WITH THIS
>      RETURN .oRegExp2.REPLACE(.oRegExp1.REPLACE(cString,""),"")
>    ENDWITH
>  ENDFUNC
>ENDDEFINE
>Good luck,
>Viv
Malcolm Greene
Brooks-Durham
mgreene@bdurham.com
Previous
Reply
Map
View

Click here to load this message in the networking platform