Extract HTML page title - ColdFusion regular expression

To extract a page title from a HTML page that has either been pulled from CFHTTP, a stored local file or from the ColdFusion page output:-

<cfset pageTitle = "">
<cfset RegExp = REFindNoCase("(<title[>])(.*)(<\/title>)", myFile, 1, True)>
<cfif RegExp.len[1] gt 0>
  <cfset pageTitle = mid(myFile, RegExp.pos[3], RegExp.len[3])>
</cfif>

Extract HTML page title - ColdFusion regular expression

To extract a page title from a HTML page that has either been pulled from CFHTTP, a stored local file or from the ColdFusion page output:-

<cfset pageTitle = "">
<cfset RegExp = REFindNoCase("(<title[>])(.*)(<\/title>)", myFile, 1, True)>
<cfif RegExp.len[1] gt 0>
  <cfset pageTitle = mid(myFile, RegExp.pos[3], RegExp.len[3])>
</cfif>
BlogCFC was created by Raymond Camden. This blog is running version 5.9.5.002. Contact Blog Owner