Link to home
Start Free TrialLog in
Avatar of pjordanna
pjordanna

asked on

CLEAN TXT STRING FOR SQL DB

Hi Experts,

I need a quick function to clean up all non text/numeric characters from a text string.

i.e. str = "1234dghfery"£$%^&*(''|\\"

Becomes

str = "1234dghfery"



Thanks,




PJORDANNA
ASKER CERTIFIED SOLUTION
Avatar of hongjun
hongjun
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of esw074
esw074

A regular expression is the best way to handle this.      

        Dim regEx
      Set regEx = New RegExp
      regEx.Global = true
      regEx.Pattern = "[^0-9_a-z A-Z]"


Use like:  cleanedstr = regex.replace(str, "")
Ah, just a second apart - hongjun and I posted basically the same thing.
do something like this

<%
Function noSpecChar(hmm)
      Dim regEx
      Set regEx = New RegExp
      regEx.Global = true
      regEx.Pattern = "[^0-9a-z A-Z]"
      noSpecChar = regEx.Replace(hmm,"")
End Function
response.write noSpecChar("AKJHgkjhakhskUYIy87687$%&^%*^*")
%>
rats.........same here   LOL
LOL well, at least we have consensus.
:-)
honestly now.
the 3 of us came up with the same exact answer.

I think you should split the points at least between hongjun and esw074, as they were 1st to answer it