Extract HTML page title - ColdFusion regular expression
Related Categories: ColdFusion Regular Expressions
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 RegExp = REFindNoCase("(<title[>])(.*)(<\/title>)", myFile, 1, True)>
<cfif RegExp.len[1] gt 0>
<cfset pageTitle = mid(myFile, RegExp.pos[3], RegExp.len[3])>
</cfif>
ColdFusion - CFFORM (1) [RSS]
ColdFusion Regular Expressions (5) [RSS]
ColdFusion tips (2) [RSS]
database (1) [RSS]
Graphics software (1) [RSS]
JRun errors (1) [RSS]
Leisure time (3) [RSS]
Misc (2) [RSS]
Newly released BeetrootStreet websites (12) [RSS]
Search engine preparation (4) [RSS]
SQL Server hints and tips (1) [RSS]
Web application development (2) [RSS]
| Mon | Tue | Wed | Thu | Fri | Sat | Sun |
|---|---|---|---|---|---|---|
| 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 |
Adobe Dreamweaver CS3 crashes when selecting text in code view
Greg said: Thanks... just had the same problem and this fixed it in a jiffy.
[More]
Adobe Dreamweaver CS3 crashes when selecting text in code view
Johnny said: Let me join the crowd and say THANKS!!!!
[More]
Adobe Dreamweaver CS3 crashes when selecting text in code view
Michael Markowski said: Thanks a million for this. I was going insane trying to make a few simple ColdFusion code edits in ...
[More]
Adobe Dreamweaver CS3 crashes when selecting text in code view
CAZ said: With my DW8, I had *also* to delete the Configuration dir.
If you need to do that too, I advise you...
[More]
Adobe Dreamweaver CS3 crashes when selecting text in code view
Jake said: Great. Thanks to google and thanks to you. With out both of them I'd still be trying to open Dreamwe...
[More]

it'll make it non-greedy, and try to select as little text as possible that matches the criteria.
<cfset pageTitle = "">
<cfset RegExp = REFindNoCase("<title\b[^>]*?>([^<]+)</title>", cfhttp.fileContent, 1, True)>
<cfif RegExp.len[2] gt 0><!--- Get 2nd grouping --->
<cfset pageTitle = mid(cfhttp.fileContent, RegExp.pos[2], RegExp.len[2])>
</cfif>