Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Quickly alltrim non-alpha chars from string
Message
De
03/08/2005 09:57:19
 
 
À
03/08/2005 05:21:12
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9
Divers
Thread ID:
01037589
Message ID:
01038110
Vues:
27
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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform