Don't forget to check CFLib for things like this...

http://www.cflib.org/udf/firstParagraph

-Cameron

On Mon, Jun 4, 2012 at 11:19 AM, Robert Harrison <[email protected]
> wrote:

>
> Trying to write a function to get the first paragraph in a string. My test
> string is:
>
>                <h2>Remove the a header</h2><p>This is the marigold
> following the header. This is more.</p><p>This is another paragraph.</p>
>
> The idea is two steps: Get everything to the LEFT of the </p> (this
> works), then get everything to the right of the first <p> tag... this is
> working strangely. Any thoughts? The trouble is in the Right extract.
>
> function getFirstParagraph(str) {
>    str = trim(str);
>    endTag = findNoCase("</p>", str);
>    startTag = findNoCase("<p>", str);
>    if (endTag gt 0) {
>        endTag = endTag + 3;
>        extract = left(str, endTag);
>    } else {
>        extract = str;
>    }
>    if (startTag gt 0) {
>        startTag = startTag + 4;
>        extract = right(extract, startTag);
>    } else {
>        extract = str;
>    }
>    return extract;
> }
> </cfscript>
>
> <cfoutput>#getFirstParagraph(comment)#</cfoutput>
>
>
> 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
>
>
-- 
Cameron Childress
--
p:   678.637.5072
im: cameroncf
facebook <http://www.facebook.com/cameroncf> |
twitter<http://twitter.com/cameronc> |
google+ <https://profiles.google.com/u/0/117829379451708140985>


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:351440
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to