|
Mailing Lists
|
Home /
Groups /
ColdFusion Talk (CF-Talk)
Get First Paragraph: Remove Empty Paragraphs
Getting close, no I'm trying to consider any empty paragraphs. Tried this:Robert Harrison 06/04/12 12:37 P ? 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>Robert Harrison 06/04/12 12:51 P <cfsavecontent variable="myString">Matt Quackenbush 06/04/12 01:04 P Matt,Robert Harrison 06/04/12 02:29 P I don't recall the exact characters, but \w will include some otherMatt Quackenbush 06/04/12 02:49 P Hmm. I just tried a couple of non-printable character insertions, andMatt Quackenbush 06/04/12 03:00 P 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 ? 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 <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 ----- 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_ 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 ----- 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 -----
|
May 20, 2013
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||