Well, this seems to be solved so I should share it. Thanks to those who helped. 

This function takes an HTML text string and extracts the first paragraph (i.e., 
the first displayable text string wrapped in P tags). It ignores any images, 
headers, empty P tags, etc., and returns only the first actual paragraph. Works 
with HTML editors like tinyMCE. 

Code is: 

        <!--- this method returns the first paragraph (wrapped in P tags) in an 
HTML string --->
        <cffunction name="GetFirstParagraph" returntype="string" 
access="public" output="false">
                <cfargument name="html_text" type="string" required="yes" />
                <cfset 
ExtractionString="#reReplaceNoCase(html_text,'<p>([^\w*?])*</p>','','all' )#">
                <cfset 
ExtractionString="#reReplaceNoCase(ExtractionString,'<p>([\s]|\&nbsp;)*</p>','','all')#">
                <cfset 
startExtractPosition=FindNoCase("<p>",ExtractionString)+3>
                <cfset endExtractPosition=FindNoCase("</p>",ExtractionString)>
                <cfset 
ExtractStringLength=endExtractPosition-startExtractPosition>
                <cfset 
ExtractionString=Mid(ExtractionString,startExtractPosition,ExtractStringLength)>
                <cfreturn ExtractionString>
        </cffunction>


What a pain that was. Thanks for the help.

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_wi

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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:351453
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to