House of Fusion
Search over 2,500 ColdFusion resources here
  
Home of the ColdFusion Community

Mailing Lists
Home /  Groups /  ColdFusion Talk (CF-Talk)

Get First Paragraph: Remove Empty Paragraphs

  << Previous Post |  RSS |  Sort Oldest First |  Sort Latest First |  Subscribe to this Group Next >> 
Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Robert Harrison
06/04/2012 12:37 PM

Getting close, no I'm trying to consider any empty paragraphs. Tried this:   <cfset ExtractionString=ReplaceList(comment,"<p></p>,<p> </p>,<p> </p>"," , , ")> But it does not work completely. How could I remove all paragraphs that are empty, or contain only blanks or non-breaking spaces? Robert Harrison Director of Interactive Services Austin & Williams Advertising I Branding I Digital I Direct   125 Kennedy Drive,  Suite 100   I  Hauppauge, NY 11788 T 631.231.6600 X 119   F 631.434.7022   http://www.austin-williams.com Blog:      http://www.austin-williams.com/blog Twitter:  http://www.twitter.com/austin_williams Subject: Re: Get First Pa

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Robert Harrison
06/04/2012 12:51 PM

? No one know a method to strip empty paragraphs from a string?   I'd like to remove all occurrences of paragraphs that have no content - stuff like: , <p></p> OR <p> </p> OR <p> </p> Any ideas? Thanks Robert Harrison Director of Interactive Services Austin & Williams Advertising I Branding I Digital I Direct   125 Kennedy Drive,  Suite 100   I  Hauppauge, NY 11788 T 631.231.6600 X 119   F 631.434.7022   http://www.austin-williams.com Blog:      http://www.austin-williams.com/blog Twitter:  http://www.twitter.com/austin_williams Getting close, no I'm trying to consider any empty paragraphs. Tried this:   <cfset ExtractionString=ReplaceList(comment,"<p></p>,<p> </p>,<p> </p>"," , , ")> But it does not work completely. How could I remove all paragraphs that are empty, or contain only blanks or non-breaking spaces? Robert Harrison Director of Interactive Services Austin & Williams Advertising I Branding I Digital I Direct 125 Kennedy Drive,  Suite 100   I  Hauppauge, NY 11788 T 631.231.6600 X 119   F 631.434.7022 http://www.austin-williams.com Blog:      http://www.austin-williams.com/blog Twitter:  http://www.twitter.com/austin_williams

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Matt Quackenbush
06/04/2012 01:04 PM

<cfsavecontent variable="myString"> <p>This is the opening paragraph.</p> <p></p> <p> </p> <p>      </p> <p>                 </p> <p>This is the closing paragraph.</p> </cfsavecontent> <cfdump var="#reReplaceNoCase( myString, '<p>([\s]|\ )*</p>', '', 'all' )#" /> On Mon, Jun 4, 2012 at 11:50 AM, Robert Harrison <robert@austin-williams.com ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Robert Harrison
06/04/2012 02:29 PM

Matt, I tried your solutions and it works 100%, except when it's my variable from the form. It's a tiny MCE field and it seems it must be inserting some non-printable character.  I changed the statement   From this:     #reReplaceNoCase(myString, '<p>([\s]|\ )*</p>', '', 'all' )#      To This:  #reReplaceNoCase(myString,'<p>([^\w*?])*</p>','','all' )# This seems to be working. Can someone that knows regex better that I confirm the "to this" says:    Strip from <p> to </p> UNLESS it contains a letter or a number? I think that's what it says. Is that right? Thanks Robert Harrison Director of Interactive Services Austin & Williams Advertising I Branding I Digital I Direct   125 Kennedy Drive,  Suite 100   I  Hauppauge, NY 11788 T 631.231.6600 X 119   F 631.434.7022   http://www.austin-williams.com Blog:      http://www.austin-williams.com/blog Twitter:  http://www.twitter.com/austin_

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Matt Quackenbush
06/04/2012 02:49 PM

I don't recall the exact characters, but \w will include some other characters. Maybe this will also work for you? reReplaceNoCase( myString, '<p>([\s]|\ |[^[:print]])*</p>', '', 'all' ) I think that's more clear as to intent. I prefer to be more explicit, but it's really just personal preference. :-) On Mon, Jun 4, 2012 at 1:29 PM, Robert Harrison <robert@austin-williams.com>wrote: ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Matt Quackenbush
06/04/2012 03:00 PM

Hmm. I just tried a couple of non-printable character insertions, and [^[:print]] does not catch them. Mayhaps [\w] is better after all. ;-) (BTW, I went and looked up \w for a refresher: "Any alphanumeric character, or the underscore (_), similar to [[:word]]" ) On Mon, Jun 4, 2012 at 1:49 PM, Matt Quackenbush <quackfuzed@gmail.com>wrote: ----- Excess quoted text cut - see Original Post for more -----


<< Previous Thread Today's Threads Next Thread >>

Search cf-talk

May 20, 2013

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
       1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31   

Designer, Developer and mobile workflow conference