• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Remove "<p> </p>" code

Participant ,
Sep 19, 2013 Sep 19, 2013

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?

Views

919

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Participant , Sep 30, 2013 Sep 30, 2013

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>&#160;</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".

Votes

Translate

Translate
Guide ,
Sep 19, 2013 Sep 19, 2013

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 19, 2013 Sep 19, 2013

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Sep 19, 2013 Sep 19, 2013

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 19, 2013 Sep 19, 2013

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...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 28, 2013 Sep 28, 2013

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!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 28, 2013 Sep 28, 2013

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>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 29, 2013 Sep 29, 2013

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 30, 2013 Sep 30, 2013

Copy link to clipboard

Copied

LATEST

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>&#160;</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".

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation