Skip to main content
Known Participant
March 21, 2013
Question

How do I preserve '<' and HTML tags in my output?

  • March 21, 2013
  • 2 replies
  • 2367 views

Our clients tend to enter both single angle brackers (i.e. "hours <4") and the HTML tags into a form field. We can not use HTMLEditFormat() on the field since they want their formatting preserved. At the same time, using a single bracket trancates the field output.

Is there a way to distinguish  a single "<" from the beginning of an HTML tag so we can internally substitute it with &lt;?

Thanks for your advice!

This topic has been closed for replies.

2 replies

Known Participant
March 22, 2013

<cfset newvalue = #ReReplace(yourinputfield,"&lt;","<","ALL")#>

That will replace ALL instances of a <  with &lt;

Unless I misunderstood what you're asking.

Participating Frequently
March 22, 2013

What exactly you want to do? can you explain more detail's.

glamorous_Wonder6C1C
Inspiring
March 21, 2013

I am not sure what do you want so say by "We can not use HTMLEditFormat() on the field since they want their formatting preserved".

But it seems that you can take help of regular expression.

First you have make a regular expression for detecting html tag. If make not of that expression you will get everything except html and for that you need to replace "<".

Anyway it will helpfull if you provide some more details regarding formatting.

Inspiring
March 22, 2013

Regarding - We can not use HTMLEditFormat() on the field since they want their formatting preserved.

If data is entered into a rich textearea, it will have html tags such as <b>.  Every line break will be create <p></p>.  If you output this using HTMLEditFormat(), or not only will these tags not function, but they will display.

It's a difficult question.

el_simAuthor
Known Participant
March 25, 2013

Thank you. You gave a very clear description of our problem. Do you think it's possible to construct an adequate Reg Ex for this case?