469,352 Members | 2,154 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,352 developers. It's quick & easy.

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 6168
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by QueenArenA.com | last post: by
2 posts views Thread by Richard S. Crawford | last post: by
2 posts views Thread by johkar | last post: by
2 posts views Thread by Joebloggs | last post: by
3 posts views Thread by tma | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.