Copy link to clipboard
Copied
Hi all, I have a difficulty removing this code "<p> </p>" with replace.
The code in the cfdump is:
</p> <p> </p> <p>
in the html output it is:
<p>
Tijdens de volle maan vanavond wordt een optische illusie zichtbaar die mensen al sinds de tijd van Aristoteles voor een raadsel stelt.</p>
<p>
</p>
<p>
De maan lijkt een stuk groter te zijn naarmate deze zich dichter bij de horizon bevindt dan wanneer deze hoger aan de hemel staat.</p>
<p>
</p>
Any idea's?
Finally got the solution!
Using a filter function by: http://www.bennadel.com/index.cfm?event=blog.viewcode&id=1155&index=1
I saw that the mysterious empthy space <p> </p> was replaced by <p> </p>.
Next was a simple:
<cfset text = ReplaceNoCase(text, "<p>&##160;</p>", "", "ALL")>
and all is fine...
So, the bottom line is "know what you are looking for".
Copy link to clipboard
Copied
Are you just trying to remove the empty <p></p> tag pairs, or all of the <p></p> tags and their content?
Copy link to clipboard
Copied
Hi thanks for your answer, I am indeed trying just to remove the empthy <p></p> tags, but because there is spave between those tags and around them I have great problems removing it with replace, I guess I need a regular expression?
Copy link to clipboard
Copied
Yes, that was going to be my next suggestion, although I couldn't tell you what that RegEx would look like. Good luck!
-Carl V.
Copy link to clipboard
Copied
Well that means I am moving in the right direction then, thanks, I will give it a Google once more...
Copy link to clipboard
Copied
Well, I am really suprised that this is so hard to do, al I can find is info about using a html filter. I really only need to replace "<p> </p>", why isn't it easily possible with replace code?
Does anyone know of a regex that works for replacing "<p> </p>" ?
Thanks!
Copy link to clipboard
Copied
<cfscript>
string = "<p>Don't Delete Me 1!</p>
<p>
</p>
<P>Don't Delete Me 2!</p>
<p>
</P>
<p>I hope it doesn't delete me 3!</p>
";
writeOutput( '<textarea>#reReplaceNoCase( string, '<p>[[:space:]]*</p>', "", "ALL")#</textarea>' );
</cfscript>
Copy link to clipboard
Copied
Hi thanks for your reply, your example works perfect, only when I try to use it in my code it doesn't work, here's what I do:
<cfset text = REReplaceNoCase(text, '<p>[[:space:]]*</p>', "", "ALL")>
<cfoutput>#text#</cfoutput>
<cfabort>
giving me:
<p>
Maar stilte hebben we nodig om onszelf te vinden. Weten wie we in werkelijkheid zijn, wat onze missie of doelstelling in dit leven is.</p>
<p>
</p>
<p>
Stilte geeft ons kracht</p>
Is the cfscript writeoutput treated differently?
Copy link to clipboard
Copied
Finally got the solution!
Using a filter function by: http://www.bennadel.com/index.cfm?event=blog.viewcode&id=1155&index=1
I saw that the mysterious empthy space <p> </p> was replaced by <p> </p>.
Next was a simple:
<cfset text = ReplaceNoCase(text, "<p>&##160;</p>", "", "ALL")>
and all is fine...
So, the bottom line is "know what you are looking for".