| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
Function to strip multiple characters from string ASP
This function is very handy for stripping special characters out especially before inserting into a database. You have the ability to alter the characters you require removed.
You can change the characters you want to remove in the array and if you add orr remove any simply change the iCounter number accordingly Code:
<%
Function StripSpecialChar(inFileName)
dim sOut,strorigFileName,arrSpecialChar,intCounter
arrSpecialChar = Array("%20","%"," ","#","+","(",")","&","$","@","!","*","<",">","?","/","|","\",",","-")
strorigFileName = inFileName
intCounter = 0
Do Until intCounter = 20
sOut = replace(strorigFileName,arrSpecialChar(intCounter) ,"")
intCounter = intCounter + 1
strorigFileName = sOut
'response.write strorigFileName
Loop
StripSpecialChar = response.write(strorigFileName)
end Function
%>
To call this function simply as follows Code:
<%
Call StripSpecialChar("I want# to strip+ @specific- characters")
%>
|
|
#2
|
||||
|
||||
|
--moved to the Code Bank.
Welcome to the forum and thanks for sharing this! ![]() |
|
#3
|
|||
|
|||
|
Trying to strip a request.form item
Hi,
Tried using StripSpecialChar on a recordset item, and it worked first time . . . which is a rare event for me . . . But then I tried using it for a request.form item and the wheels fell off. What I want to do is strip special characters out of a form field named "message". Can anyone offer some advice please? I'm using dreamweaver if that's any help (or hindrance!) |
|
#4
|
||||
|
||||
|
please post a thread in the proper forum with your problem. also, please post the code that you're using and indicate what error message you're receiving along with which line of code it is referring to.
__________________
Come JOIN the party!!! Quote of the Month: Stupidity: Quitters never win, winners never quit, but those who never win AND never quit are idiots. Questions to Ponder: If man evolved from monkeys and apes, why do we still have monkeys and apes? iif([sarcasm]=true,iif([you have to ask]=true,"didn't work","ha ha ha"),"not sarcasm") copyright© 2008 sbenj69 |
|
#5
|
|||
|
|||
|
Quote:
Sorry about that. A basic amateur mistake x 2. Please feel free to delete this post and my last one. Thanks. |
|
#6
|
||||
|
||||
|
Quote:
![]() |
![]() |
| Viewing: ASP Free Forums > Programming > Code Bank > Handy Function to strip unwanted characters from string ASP |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|