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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remove special characters 1

Status
Not open for further replies.

GaryC123

Programmer
Sep 10, 2002
1,041
NO
How can i remove the special characters from a field in a recordset. i.e. things like carriage returns,tabs etc that dont actually show up.



 
try regular expression replace methods

____________________________________________________
The most important part of your thread is the subject line.
Make it clear and about the topic so we can find it later for reference. Please!! faq333-3811

onpnt2.gif
 
thread333-561262

____________________________________________________
The most important part of your thread is the subject line.
Make it clear and about the topic so we can find it later for reference. Please!! faq333-3811

onpnt2.gif
 
I can't get my head around regex, what would the exression be?

If I have this

strRegExp = intSteps
Set RegExpObj = New RegExp
With RegExpObj
.Pattern =
What's pattern I need to replace everything but numbers, characters,periods, dashes etc everything that might be in a normal text

.IgnoreCase = True
.Global = True
End With

strReplaced = RegExpObj.Replace(strRegExp, "")





 
well, the pattern specifics need to be slightly more clear
then that list but we can try a example
in your original post you stated carriage returns,tabs etc

so lets show these replacments.

the pattern to match a carriage return is \r
and the for tab is \t
list of these and many, many more here
and this also
i love this page. use it every day [wink]

alright, so take that into effect and use it
Sorry, I hate the with statement.

Function ReplaceTest(str)
'delcare the var needed
Dim regEx
Set regEx = New RegExp
here's is the most important postion of the function obviously
the pattern will seem like gibberish at first but after awhile
it gets to be as any other syntax in your coding
so we have \r and \t for the pattern

regEx.Pattern = "[\r\t]"
regEx.Global = True
very important in vbscript. if this setting "global" is
not true you only get one match and one replacement

regEx.IgnoreCase = True
'apply to value
response.write regEx.Replace(str,"Replaced Here!")
End Function

there is no magic to this or regex in general. the pattern is obviously the tough
beginning but after you read up a bit it really isn't that difficult

____________________________________________________
The most important part of your thread is the subject line.
Make it clear and about the topic so we can find it later for reference. Please!! faq333-3811

onpnt2.gif
 
well for carraige return:
str=replace(str,vbcrlf,"")

tab:
str=replace(str,vbtab,"")



Known is handfull, Unknown is worldfull
 
ya, but you would have to run through a replace function for each tab, carriage, vert tab, feed, new line, etc..
regEx you can get all of them with a simple
"\t\r\v\f\n\e"
one hit one call

I'll talk you into Regular Expressions if it's the last thing I do vbkris [wink]

____________________________________________________
The most important part of your thread is the subject line.
Make it clear and about the topic so we can find it later for reference. Please!! faq333-3811

onpnt2.gif
 
So hurry up and find an example using RegExp's with Python and send it to me, I don't have time to look for it myself today :)

01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111
minilogo.gif alt=tiernok.com
The never-completed website
 
hmm..
>>> p = re.compile('\r\t')
>>> p.sub( '', value to search and replace here)

could it get any harder then that [lol]

____________________________________________________
The most important part of your thread is the subject line.
Make it clear and about the topic so we can find it later for reference. Please!! faq333-3811

onpnt2.gif
 
of course that is from the python shell if anyone tries it.


____________________________________________________
The most important part of your thread is the subject line.
Make it clear and about the topic so we can find it later for reference. Please!! faq333-3811

onpnt2.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top