Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
To clean a string
Message
 
 
À
16/12/2000 08:15:52
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00454334
Message ID:
00454373
Vues:
26
>>>I want a small prog or solution to clean a string which will remove all things execpt numbers and Alphbets.
>>>
>>>e.g:
>>>Original string is "abcd ## 55 JJJ )))345 )) +++++"
>>>Result I should get: "ABCD55JJJ345"
>>>RESULT IS IN UPPERCASE:

>>Rahul, a handy trick is to call CHRTRAN twice:
>>lcOrig = "abcd ## 55 JJJ )))345 )) +++++"
>>lcOrig = upper(lcOrig)
>>lcClean = chrtran(lcOrig, chrtran(lcOrig, "01234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ",""), "")
>>
>>That way you are certain to get only what you want.
Why not apply the UPPER to the results of the CHRTRAN()'s which should (consequently) be shorter, and also faster (being a one-liner):
lcClean = upper( chrtran(lcOrig, chrtran(lcOrig, "01234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ",""), ""))
censored.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform