473,320 Members | 2,158 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

function that removes the punctuation and some characters like (*&^%$#@!<>?"} from a text string

Hi All;

I'm trying to create an ASP function called CleanX that removes the
punctuation and some characters like (*&^%$#@!<>?"}|{..) from a text
string

I came up with this but It doesn't look like it's working.

Can anyone help please.
THANK YOU.
Function CleanX(strString)

yTemp = strString
yTemp = replace(yTemp,"*","")
yTemp = replace(yTemp,"!","")
yTemp = replace(yTemp,"""","")
yTemp = replace(yTemp,"£","")
yTemp = replace(yTemp,"$","")
yTemp = replace(yTemp,"%","")
yTemp = replace(yTemp,"^","")
yTemp = replace(yTemp,"&","")
yTemp = replace(yTemp,"(","")
yTemp = replace(yTemp,")","")
yTemp = replace(yTemp,"_","")
yTemp = replace(yTemp,"-","")
yTemp = replace(yTemp,"=","")
yTemp = replace(yTemp,"+","")
yTemp = replace(yTemp,"#","")
yTemp = replace(yTemp,"~","")
yTemp = replace(yTemp,"[","")
yTemp = replace(yTemp,"{","")
yTemp = replace(yTemp,"]","")
yTemp = replace(yTemp,"}","")
yTemp = replace(yTemp,";","")
yTemp = replace(yTemp,":","")
yTemp = replace(yTemp,"@","")
yTemp = replace(yTemp,"'","-")
yTemp = replace(yTemp,"<","")
yTemp = replace(yTemp,",","")
yTemp = replace(yTemp,">","")
yTemp = replace(yTemp,".","")
yTemp = replace(yTemp,"?","")
yTemp = replace(yTemp,"/","")
yTemp = replace(yTemp,"\","")
yTemp = replace(yTemp,"|","")
yTemp = replace(yTemp,"¬","")
yTemp = replace(yTemp,"`","")
yTemp = replace(yTemp,"é","e")
yTemp = replace(yTemp,"è","e")
yTemp = replace(yTemp,"à","a")
yTemp = replace(yTemp,"ï","i")
yTemp = replace(yTemp,"ê","e")
yTemp = replace(yTemp,"â","a")
yTemp = replace(yTemp,"ô","o")
strString = yTemp
End Function


Jul 19 '05 #1
8 6404
Your last line should be CleanX=yTemp
You may want to look into Regular Expressions, as it may be easier and
faster.

"Beznas" <wa***@walou.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi All;

I'm trying to create an ASP function called CleanX that removes the
punctuation and some characters like (*&^%$#@!<>?"}|{..) from a text string

I came up with this but It doesn't look like it's working.

Can anyone help please.
THANK YOU.
Function CleanX(strString)

yTemp = strString
yTemp = replace(yTemp,"*","")
yTemp = replace(yTemp,"!","")
yTemp = replace(yTemp,"""","")
yTemp = replace(yTemp,"£","")
yTemp = replace(yTemp,"$","")
yTemp = replace(yTemp,"%","")
yTemp = replace(yTemp,"^","")
yTemp = replace(yTemp,"&","")
yTemp = replace(yTemp,"(","")
yTemp = replace(yTemp,")","")
yTemp = replace(yTemp,"_","")
yTemp = replace(yTemp,"-","")
yTemp = replace(yTemp,"=","")
yTemp = replace(yTemp,"+","")
yTemp = replace(yTemp,"#","")
yTemp = replace(yTemp,"~","")
yTemp = replace(yTemp,"[","")
yTemp = replace(yTemp,"{","")
yTemp = replace(yTemp,"]","")
yTemp = replace(yTemp,"}","")
yTemp = replace(yTemp,";","")
yTemp = replace(yTemp,":","")
yTemp = replace(yTemp,"@","")
yTemp = replace(yTemp,"'","-")
yTemp = replace(yTemp,"<","")
yTemp = replace(yTemp,",","")
yTemp = replace(yTemp,">","")
yTemp = replace(yTemp,".","")
yTemp = replace(yTemp,"?","")
yTemp = replace(yTemp,"/","")
yTemp = replace(yTemp,"\","")
yTemp = replace(yTemp,"|","")
yTemp = replace(yTemp,"¬","")
yTemp = replace(yTemp,"`","")
yTemp = replace(yTemp,"é","e")
yTemp = replace(yTemp,"è","e")
yTemp = replace(yTemp,"à","a")
yTemp = replace(yTemp,"ï","i")
yTemp = replace(yTemp,"ê","e")
yTemp = replace(yTemp,"â","a")
yTemp = replace(yTemp,"ô","o")
strString = yTemp
End Function

Jul 19 '05 #2
> You may want to look into Regular Expressions, as it may be easier and
faster.

Tom;

I'm not sure I got that right.
What do you mean by regular expressions? Also where do you want me to put
the CleanX=yTemp ?
Thanks a lot.

"Tom B" <sh*****@NOSPAMhotmail.com> wrote in message
news:Ob**************@TK2MSFTNGP09.phx.gbl... Your last line should be CleanX=yTemp
You may want to look into Regular Expressions, as it may be easier and
faster.

"Beznas" <wa***@walou.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi All;

I'm trying to create an ASP function called CleanX that removes the
punctuation and some characters like (*&^%$#@!<>?"}|{..) from a

text
string

I came up with this but It doesn't look like it's working.

Can anyone help please.
THANK YOU.
Function CleanX(strString)

yTemp = strString
yTemp = replace(yTemp,"*","")
yTemp = replace(yTemp,"!","")
yTemp = replace(yTemp,"""","")
yTemp = replace(yTemp,"£","")
yTemp = replace(yTemp,"$","")
yTemp = replace(yTemp,"%","")
yTemp = replace(yTemp,"^","")
yTemp = replace(yTemp,"&","")
yTemp = replace(yTemp,"(","")
yTemp = replace(yTemp,")","")
yTemp = replace(yTemp,"_","")
yTemp = replace(yTemp,"-","")
yTemp = replace(yTemp,"=","")
yTemp = replace(yTemp,"+","")
yTemp = replace(yTemp,"#","")
yTemp = replace(yTemp,"~","")
yTemp = replace(yTemp,"[","")
yTemp = replace(yTemp,"{","")
yTemp = replace(yTemp,"]","")
yTemp = replace(yTemp,"}","")
yTemp = replace(yTemp,";","")
yTemp = replace(yTemp,":","")
yTemp = replace(yTemp,"@","")
yTemp = replace(yTemp,"'","-")
yTemp = replace(yTemp,"<","")
yTemp = replace(yTemp,",","")
yTemp = replace(yTemp,">","")
yTemp = replace(yTemp,".","")
yTemp = replace(yTemp,"?","")
yTemp = replace(yTemp,"/","")
yTemp = replace(yTemp,"\","")
yTemp = replace(yTemp,"|","")
yTemp = replace(yTemp,"¬","")
yTemp = replace(yTemp,"`","")
yTemp = replace(yTemp,"é","e")
yTemp = replace(yTemp,"è","e")
yTemp = replace(yTemp,"à","a")
yTemp = replace(yTemp,"ï","i")
yTemp = replace(yTemp,"ê","e")
yTemp = replace(yTemp,"â","a")
yTemp = replace(yTemp,"ô","o")
strString = yTemp
End Function


Jul 19 '05 #3
<%
Function CleanString(strData)
strData = Trim(strData)
lngLength = Len(strData)
If lngLength > 0 Then
Dim aryResult()
Redim aryResult(lngLength - 1)
For intCount = 1 To lngLength
intItem = Asc(Mid(strData,intCount,1))
If intItem = 32 Or intItem >= 48 And intItem <= 57 Or intItem >= 65 And
intItem <= 90 Or intItem >= 97 And intItem <= 122 Then
aryResult(intCount - 1) = Chr(intItem)
End If
Next
CleanString = Trim(Join(aryResult,""))
End If
End Function
'Example
Response.Write CleanString("123 ABC abc ^&%")
%>

-dlbjr

invariable unerring alien
Jul 19 '05 #4
Beznas wrote on 10 sep 2003 in microsoft.public.inetserver.asp.general:
What do you mean by regular expressions?


Function CleanX(strString)
Set regEx = New RegExp
regEx.Pattern = "[^a-z0-9 ]+"
regEx.IgnoreCase = True
regEx.Global = True
CleanX = regEx.Replace(strString, "")
End Function

response.write CleanX("123 @@()z{}ABC abc ^&%")

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 19 '05 #5
Thank you Everjan; dlbjr for your help.

Both your functions work great Except that I wasn't clear on my question.

Actually I'm trying to parse some text retrived from a database to an XML
file. XML doesn't like French characters such as:

éèàïêâô

So I'm trying to replace those characters with their relatives in Standard
English Characters LCID 1036 such as:

eeaieao

So I think we need 2 arrays of characters: The ones that should be replaced
and the replacements.
The function should look for any of those characters and replace it with its
relative in English.

Also remove *!£$%^&()_-=+#~[{]};:@<,>.?/\|¬`
I tried removing éèàïêâô without replacing and the output came out
nonesense.
Thank You all for your help.
I love you.


"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn********************@194.109.133.29...
Beznas wrote on 10 sep 2003 in microsoft.public.inetserver.asp.general:
What do you mean by regular expressions?


Function CleanX(strString)
Set regEx = New RegExp
regEx.Pattern = "[^a-z0-9 ]+"
regEx.IgnoreCase = True
regEx.Global = True
CleanX = regEx.Replace(strString, "")
End Function

response.write CleanX("123 @@()z{}ABC abc ^&%")

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Jul 19 '05 #6
Beznas wrote on 10 sep 2003 in microsoft.public.inetserver.asp.general:
Actually I'm trying to parse some text retrived from a database to an
XML file. XML doesn't like French characters such as:

éèàïêâô

So I'm trying to replace those characters with their relatives in
Standard English Characters LCID 1036 such as:

eeaieao


<%
Function CleanX(strString)
Set regEx = New RegExp
regEx.Pattern = "[^a-z0-9 ]+"
regEx.IgnoreCase = True
regEx.Global = True
CleanX = regEx.Replace(strString, "")
End Function

function deleteaccents(text)
text = CleanX(text)

olds = "éèàïêâôÉÈÀÏÊÂÔ"
news = "eeaieaoEEAIEAO"

for i=1 to len(text)
c=mid(text,i,1)
n = instr(olds,c)
if n>0 then c=mid(news,n,1)
t = t & c
next
deleteaccents = t
end function

response.write deleteaccents("éèàïêâôÉÈÀÏÊÂÔ")
%>
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 19 '05 #7
Thanks Evertjan but the output of deleteaccents is blank!!!!!!!!
Try it. Any ideas??
<%
Function CleanX(strString)
Set regEx = New RegExp
regEx.Pattern = "[^a-z0-9 ]+"
regEx.IgnoreCase = True
regEx.Global = True
CleanX = regEx.Replace(strString, "")
End Function

function deleteaccents(text)
text = CleanX(text)

olds = "éèàïêâôÉÈÀÏÊÂÔ"
news = "eeaieaoEEAIEAO"

for i=1 to len(text)
c=mid(text,i,1)
n = instr(olds,c)
if n>0 then c=mid(news,n,1)
t = t & c
next
deleteaccents = t
end function
response.write deleteaccents("éèàïêâôÉÈÀÏÊÂÔ")
%>
Jul 19 '05 #8
Beznas wrote on 10 sep 2003 in microsoft.public.inetserver.asp.general:
Thanks Evertjan but the output of deleteaccents is blank!!!!!!!!
Try it. Any ideas??


Sorry, the accented chars are deleted by the clearX

Solution see the practical test:

<http://devrijehuisarts.org/test/deleteaccents.asp>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 19 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: QueenArenA.com | last post by:
I have a big problems because I have to query a database which contents contains some - ' - characters and obviously the query back with errors. An example is in www.queenarena.com/turbol.php ...
2
by: Richard S. Crawford | last post by:
I have a large table, tblMessage, which stores e-mail messages in text fields. I need to remove the carriage returns the data in these fields, but I have not yet figured out how to do so. I...
4
by: grghoward | last post by:
I am receiving a series of Microsoft Word documents from web clients that they upload to my server. I need to convert them to XML to pass through to another system. I have done this through...
2
by: johkar | last post by:
Would there ever be any problems with the following script depending on what type of characters are in the text string? I am appending the value of hidden form field to the query string. ...
2
by: Joebloggs | last post by:
Hi I am trying to do an ldap lookup. I can pick up the domain name in the standard format DOMAIN\USERNAME. The problem is the company I work for expects the query in the format DOMAIN:USERNAME....
3
by: tma | last post by:
I have a web form where users enter basic information such as their name and address. How can I ensure that when that data gets written to the database it gets "converted" to first letter capital,...
11
by: .Net Sports | last post by:
In VB.net, I'm trying to do a couple of things in a couple of different blocks of code. I need to take the first 25 characters of a text file, then append at the end some ellipses and a MORE link...
11
by: Ron L | last post by:
I have a barcode scanner which uses a "keyboard wedge" program so that the data it scans comes through as if it was typed on a keyboard. I am trying to have the data in the barcode be displayed in...
2
by: alxasa | last post by:
Hello, I am hoping someone can help me with this. I need a javascript function, which sits inside a <input type="text" name="firstname"> line of code. Now, if someone starts typing fine, but when...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.