Link to home
Start Free TrialLog in
Avatar of Coast Line
Coast LineFlag for Canada

asked on

Problem with the Data

Hi, I have the data coming from the database, and that data has the all kinds of special characters, My data is going back to the Page through JSON, I am using the JSStringFormat but still that is failing somewhere!

"#jsStringFormat(ReReplace(myString, '[\r\n\t"]+', '', 'ALL'))#"

if it encounter single quote, it will wreck the JSON!  and also how i do use the above rerplace to skip the double quotes and single quotes and replace with some other character or something should be done like htmleditformat so it should not the break the data

I Just tested with single quotes and it breaked, but i do not know if this will break on any other characters.

Please guide me Thanks

Avatar of kaufmed
kaufmed
Flag of United States of America image

Can you give an example of a before text and an after text?
Avatar of Coast Line

ASKER

like >>

This is the one feature's i have been testing!

The above line is coming from database so if it encounters the 's, it breaks the JSON which is sent to the Browser! I am not sure but there might be Other Special Characters like!

Double Quotes, Special Characters, etc
Avatar of dagaz_de
dagaz_de

I think \r\n will not work.

try to replace #chr(13)# and #chr(10)#
well i need to skip the

/r/n/t\' etc tags and they may be repetitive, please give a valid regex for this
i think Regex cant handle that, try:

<cfset searchlist = '#chr(13)#,#chr(10)#,#chr(9)#,"'>
<cfset replacelist = ",,,">

#jsStringFormat(Replacelist(myString, searchlist, replacelist))#

(not tested)
Based on what I find here:  http://code.google.com/p/json-simple/wiki/EscapingExamples

My guess is that you would need something like:

"#jsStringFormat(ReReplace(myString, '(["/\\\b\f\n\r\t]|\u[a-fA-F0-9]{4})', '\\\1', 'ALL'))#"

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America 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
SOLUTION
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
@dagaz_de

Thank for your code, but an u explain a bit, is seems doing toomany thigs in a singe command!, i do want to replace comma as it does not break json!

@ kaufmed  Can u please explain your code what strings or specil characters in handles and how!

Thanks
SOLUTION
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
Thanks Guys