Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
To clean a string
Message
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00454334
Message ID:
00454343
Views:
27
>>I want a small prog or solution to clean a string which will remove all things execpt numbers and Alphbets.
>
>Here is one way
>
>
>? RemoveSpecial("832i#@^&*ds7fha8732h909&*%$*%9")
>
>FUNCTION RemoveSpecial
>	PARAMETER pcString
>	LOCAL lcNew, i, lcSymbol
>	
>	lcNew = ""
>	* loop through string and remove everything except letters and numbers
>	FOR i = 1 to len(pcString)
                lcSymbol=substr(pcString,i,1) 
>		IF IsDigit(lcSymbol) or IsAlpha(lcSymbol)
>			lcNew = lcNew + substr(pcString,i,1)
>		ENDIF
>	ENDFOR
>RETURN UPPER(lcNew)
>
>
This is if we can not determine in advance all 'bad' characters. Otherwise my solution is simpler for huge strings. Also we can check FoxTools functions: (Filter?, Reduce)
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform