Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Quickly alltrim non-alpha chars from string
Message
 
 
À
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:
01038100
Vues:
20
>Hi,
>
>>>
>Thanks again for the regex approach. I'm going to use that on another, unrelated task.
>>>
>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

Would having one regexp object be slightly faster?
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform