Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best approach to remove special characters using ColdFusion and Microsoft SQL?

I want to remove all special characters (",/{}etc.) from an input field being saved as a string to the DB.

What is the best approach?

Should this check be tackled with JS, ColdFusion or Microsoft SQL - Maybe all three?

How would I go about coding this using ColdFusion or Microsoft SQL?

like image 931
Alex Avatar asked Sep 28 '10 19:09

Alex


People also ask

How do you escape special characters in Coldfusion?

Using special characters. A backslash followed by any special character matches the literal character itself, that is, the backslash escapes the special character. For example, "\+" matches the plus sign, and "\\" matches a backslash. A period matches any character, including newline.


Video Answer


1 Answers

You mean everything not alphanumeric?

I'd probably use a REReplace in the data layer.

<cfqueryparam 
  cfsqltype="cf_sql_varchar" 
  value="#REReplace(myVar,"[^0-9A-Za-z ]","","all")#" 
/>

Update: changed to include "space".

like image 63
ale Avatar answered Sep 27 '22 19:09

ale