Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Advice how to replace special chars with blank
Message
From
09/02/2005 15:36:00
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
09/02/2005 15:27:04
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00985315
Message ID:
00985338
Views:
15
>Raphael,
>
>I want these to be included :
>
>ABCDEFGHIJKLMNOPQRSTUVWZYZ
>abcdefghijklmnopqrstuvwxyz
>0123456789
>one space (
>. (period)
>- (dash)
>_ (underscore)
>
>() brakets
>
>other than above mentioned must be excluded. (' " ? * etc... )
>
>Thank again,

Ah, OK, here is the code for the solution I outlined before.
StringToClean = "abcde45-.,;"
ValidCharacters = "abcde12345"
InvalidCharacters = chrtran(StringToClean, ValidCharacters, "")
CleanString = chrtran(StringToClean, InvalidCharacters, "")
? CleanString
The two lines that do the actual calculation can be combined into one single string:
StringToClean = "abcde45-.,;"
ValidCharacters = "abcde12345"
CleanString = chrtran(StringToClean, chrtran(StringToClean, ValidCharacters, ""), "")
? CleanString
If you need it frequently, better make a UDF out of it. Add all the characters you want to keep to the variable ValidCharacters.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform