Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
To clean a string
Message
 
 
To
15/12/2000 23:42:15
Rahul Murarka
Sys-Con Engineering
Kolkata, India
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00454334
Message ID:
00454341
Views:
32
>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
	
	lcNew = ""
	* loop through string and remove everything except letters and numbers
	FOR i = 1 to len(pcString)
		IF isNumOrAlpha(substr(pcString,i,1))
			lcNew = lcNew + substr(pcString,i,1)
		ENDIF
	ENDFOR
RETURN UPPER(lcNew)

FUNCTION isNumOrAlpha
	PARAMETER pcChar
	LOCAL lnAsc
	
	lnAsc = asc(pcChar)
	IF 	lnAsc >= 97 AND lnAsc <= 122 OR ;	&& a - z
		lnAsc >= 65 AND lnAsc <= 90 OR ;	&& A - Z
		lnAsc >= 48 AND lnAsc <= 57 		&& 0 - 9
		RETURN .T.
	ENDIF
RETURN .F.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform