Skip to main content
BreakawayPaul
Inspiring
August 18, 2010
Question

Need help with ReFind

  • August 18, 2010
  • 1 reply
  • 468 views

I have a collection of CFM pages from which I need to extract the H1 text. I'm using a combination of cfdirectory, cffile, and refind. The refind step is what seems to be boogering me up.

This is what I have:

<cfdirectory directory="#expandpath("./")#" name="listfiles" filter="*.cfm">
<cfoutput query="listfiles"><cffile action="read" file="#expandpath("./")##name#" variable="result">
<cfset regex = "<div [^>]*><h1>(.+?)</h1>">
#refind(regex,result,10,"True")#
</cfoutput>

This gives me the following error:

Complex object types cannot be converted to simple values.                           

If I change the "True" in the Refind to "False" I get a series of numbers that I think are the positions that a match is found.

Any ideas what I'm doing wrong?

    This topic has been closed for replies.

    1 reply

    Inspiring
    August 18, 2010

    When you specify "true" as the last argument in ReFind() a struct is returned.

    Try replacing #refind(regex,result,10,"True")# with the sample below to look at the results.

    <cfset found=refind(regex,result,10,"True")>
    <cfdump var="#found#">

    BreakawayPaul
    Inspiring
    August 18, 2010

    Ah... of course.  That was helpful, especially after vacation-induced code-blindness.

    I used a mid() to pull what I needed out.  Thanks!