Replacing Double Quotes with REReplace()
Faced two problems whilst looping over some database entries today (with data coming from many RSS feeds, so essentially data which could contain anything).. which I can imagine other people stumbling into on occasion.
Problem One: XHMTL Which doesn't validate due &'s in a non web format
Problem Two: Title attributes in href tags closing too early due to double quotes in the string
i.e:
If
Link = http://www.somedomain.com/foo.cfm?id=1&somevar=2
and title = John Doe on "Why Should I"
Then you'd end up with the following:
This has two issues: the
should be written
, and the browser sees the title attribute as
, and then has no idea with the rest, which it assumes is your attempt as an invalid attribute in XHTML.
How to fix: Use HTMLEDITFORMAT() to escape the &'s automatically, and RegularExpression Replace - REREPLACE() - to replace the double quotes in the string with single ones.
