Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remove Characters From User Input

Status
Not open for further replies.
May 9, 2000
446
GB
Hi, can anyone give me a link / show me how to strip user input of symbols / certain characters in a function?

I'ver got a form (called form1) and a field called 'comments'. The user clicks a submit button and the page saves the input to a database, but I want to remove any ' & @ etc symbols.

Cheers
 
Hi there are a few good posts about this already on here.

The simplest way is to:

Code:
str = 'hello@youdomain.com&?'
str = Replace(str,"@")
str = Replace(str,"&")
str = Replace(str,"?")

Although you could place this logic in to a function or even use the regExp object etc..

Hope this helps

Thanks

Glen
Conception | Execution
 
Using a regular expression is the quickest way. Or you can chain replace() functions

Code:
function StripChars(strIn)
' function to remove characters from a string
' add chars into the pattern to add more
	dim objRE

	set objRE = New RegExp
	objRE.Pattern = "[&@]"
	objRE.Global = True
	StripChars = objRE.replace(strIn, "")
	set objRE = nothing
end function


Chris.

Indifference will be the downfall of mankind, but who cares?
[URL unfurl="true"]www.candsdesign.co.uk[/URL] A website that proves the cobblers kids adage.
[URL unfurl="true"]www.cram-system.com[/URL] Nightclub counting systems

So long, and thanks for all the fish.
 
have gone for the function and it works a treat thanks for the replies...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top