Ask a Question related to ASP Database, Design and Development.
-
Beznas #1
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
Beznas Guest
-
#39783 [NEW]: highlight_string function removes slashes in some cases
From: tikitiki at mybboard dot com Operating system: Not Applicable PHP version: 5.2.0 PHP Bug Type: Unknown/Other Function... -
Encrypt () places punctuation in string
:( I am encrypting a user password just before storing, the decrypting anytime it is retrieved. All works great, except for passwords that where... -
Characters with punctuation disappear
Please let someone help me with the following issue: I discovered a bug in Freehand 11.0.2: We send our Freehand postscriptfiles to the latest... -
"Access Denied" using public static Process Start(string, string);
We are using Network Associates VirusScan to check files uploaded from a web page for viruses. The code below worked fine using .Net 1.1 on... -
how to read japanese characters (multilingual characters) from a text file and save them in Access database ???
HI All i m trying to read a text file, having some japanese characters and saved as UTF-8 encoding. I m using ASP,FSO ... my code is below,... -
Beznas #2
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
Beznas Guest
-
Tom B #3
Re: function that removes the punctuation and some characters like (*&^%$#@!<>?"} from a text string
Your last line should be CleanX=yTemp
You may want to look into Regular Expressions, as it may be easier and
faster.
"Beznas" <walou@walou.com> wrote in message
news:%23weMnxydDHA.1772@TK2MSFTNGP10.phx.gbl...text> Hi All;
>
> I'm trying to create an ASP function called CleanX that removes the
> punctuation and some characters like (*&^%$#@!<>?"}|{..) from a> 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
>
>
>
>
Tom B Guest
-
Beznas #4
Re: function that removes the punctuation and some characters like (*&^%$#@!<>?"} from a text string
> 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" <shuckle@NOSPAMhotmail.com> wrote in message
news:Ob6K3$ydDHA.2168@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" <walou@walou.com> wrote in message
> news:%23weMnxydDHA.1772@TK2MSFTNGP10.phx.gbl...> text> > Hi All;
> >
> > I'm trying to create an ASP function called CleanX that removes the
> > punctuation and some characters like (*&^%$#@!<>?"}|{..) from a>> > 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
> >
> >
> >
> >
>
Beznas Guest
-
Nicole Calinoiu #5
Re: function that removes the punctuation and some characters like (*&^%$#@!<>?"} from a text string
You're not assigning the return value for the function. At the end, instead
of "strString = yTemp", try "CleanX = yTemp".
BTW, this large a number of replacements might cause a performance problem.
If so, you might want to try using a regular expressing replacement instead
(see [url]http://msdn.microsoft.com/library/en-us/script56/html/vsmthreplace.asp[/url]
for details). No guarantees that it will be faster, but it might be worth a
try if you start seeing performance problems due to this function.
HTH,
Nicole
"Beznas" <walou@walou.com> wrote in message
news:uTyaYwydDHA.3024@tk2msftngp13.phx.gbl...text> Hi All;
>
> I'm trying to create an ASP function called CleanX that removes the
> punctuation and some characters like (*&^%$#@!<>?"}|{..) from a> 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
>
>
Nicole Calinoiu Guest
-
dlbjr #6
Re: function that removes the punctuation and some characters like (*&^%$#@!<>?"} from a text string
<%
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
dlbjr Guest
-
McKirahan #7
Re: function that removes the punctuation and some characters like (*&^%$#@!<>?"} from a text string
"Beznas" <walou@walou.com> wrote in message
news:uTyaYwydDHA.3024@tk2msftngp13.phx.gbl...text> Hi All;
>
> I'm trying to create an ASP function called CleanX that removes the
> punctuation and some characters like (*&^%$#@!<>?"}|{..) from aI'm not saying it's pretty but here's an alternative:> 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
Const cNull= "*!£$%^&()_-=+#~[{]};:@<,>.?/\|¬`" & Chr(34)
Const cRepl= "'éèàïêâô"
Const cWith= "-eeaieao"
If InStr(cNull,strString) > 0 Then strString = CleanX1(strString)
If InStr(cRepl,strString) > 0 Then strString = CleanX2(strString)
Function CleanX1(strString)
Dim i, s, x
s = strString
For i = 1 To Len(cNull)
x = Mid(cNull,i,1)
s = replace(s,x,"")
Next
CleanX1 = s
End Function
Function CleanX2(strString)
Dim i, s, x, y
s = strString
For i = 1 To Len(cRepl)
x = Mid(cRepl,i,1)
y = Mid(cWith,i,1)
s = replace(s,x,y)
Next
CleanX2 = s
End Function
McKirahan Guest
-
Evertjan. #8
Re: function that removes the punctuation and some characters like (*&^%$#@!<>?"} from a text string
Beznas wrote on 10 sep 2003 in microsoft.public.inetserver.asp.general:
Function CleanX(strString)> What do you mean by regular expressions?
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)
Evertjan. Guest
-
Beznas #9
Re: function that removes the punctuation and some characters like (*&^%$#@!<>?"} from a text string
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." <exjxw.hannivoort@interxnl.net> wrote in message
news:Xns93F2648C24D37eejj99@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)
Beznas Guest
-
Evertjan. #10
Re: function that removes the punctuation and some characters like (*&^%$#@!<>?"} from a text string
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)
Evertjan. Guest
-
Beznas #11
Re: function that removes the punctuation and some characters like (*&^%$#@!<>?"} from a text string
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("éèàïêâôÉÈÀÏÊÂÔ")
%>
Beznas Guest
-
Evertjan. #12
Re: function that removes the punctuation and some characters like (*&^%$#@!<>?"} from a text string
Beznas wrote on 10 sep 2003 in microsoft.public.inetserver.asp.general:
Sorry, the accented chars are deleted by the clearX> Thanks Evertjan but the output of deleteaccents is blank!!!!!!!!
> Try it. Any ideas??
>
Solution see the practical test:
<http://devrijehuisarts.org/test/deleteaccents.asp>
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Evertjan. Guest



Reply With Quote

