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?
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.
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".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With