I recently started using the following RegEx in the ReReplace () function to cut HTML tags from a string using ColdFusion. Please note: I do not use this as protection against XSS or SQL injection; it is only to remove existing and safe HTML from the string before displaying in the HTML header attribute.
REReplaceNoCase(str,"<[^>]*>","","ALL")
In the semi-task question, I asked how to change my RegEx to include spaces and line breaks. I was told that using RegEx is not suitable for this purpose, and this post was listed as an explanation.
I strongly suspect that the regular expressions you posted are actually not working correctly. I would advise you not to use regular expressions to parse HTML, since HTML is not a common language. Use an HTML parser instead. ( Mark Byers )
If so, what is a suitable tool to remove HTML from a string before rendering? (Given that HTML is already safe, it is misinformed before entering the database).
I know HTMLEditFormat () and HTMLCodeFormat () , but these two functions do not provide what I need; the previous one replaces special characters with their HTML escaped equivalents, while the latter does the same, but also wraps the string with a <pre> .
What I would like to do is clear the line from HTML and line breaks before I display in the HTML header attribute <a title="My string without HTML goes here">...</a>
There are times when HTML is not required. For example, you want to display an excerpt from a message without HTML stored with it, for example.
source share