Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Regular Expression: Remove nonSQL-Friendly string

Author  Topic 

calvinfoo
Posting Yak Master

129 Posts

Posted - 2012-03-02 : 00:13:38
Hi Gurus,

I am using ASP 3.0 and I run the following script which I found via Google to delete any non-ASCII friendly string in my SQL Insert statement.

I only want to delete non-SQL Friendly string (not exactly non-ASCII).


sqlstr = "~!@#$%^&*()_+-=" & chr(10) & "[]\{}|;':"",./<>?"

Set objRegExp = New RegExp
objRegExp.Global = True
objRegExp.IgnoreCase = True
objRegExp.Pattern = "[^\x20-\x7E]"
sqlstr = objRegExp.Replace(sqlstr,"")


But I thik it stripped too much, It stripped even the ENTER key the chr(10), which I needed it. How to tweak the Regular Expression?

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2012-03-22 : 03:38:25
See if this helps
http://beyondrelational.com/modules/2/blogs/70/posts/10882/removing-unwanted-characters-part-2.aspx

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -