Find all alt"" params from a string - I'm halfway there but need some help

Discussion in 'Programming' started by simplymatt, Oct 29, 2010.

  1. #1
    Here's what I have:

    <cfset StartText = 'alt="'>
     <cfset Start = FindNoCase(StartText, Cfhttp.FileContent, 1)>
     <cfset EndText = '" '>
     <cfset Length = Len(StartText)>
     <cfset End = FindNoCase(EndText, Cfhttp.FileContent, Start)>
     <cfset alt = Mid(Cfhttp.FileContent, Start+Length, End-Start-Length)>
    <strong>Alt:</strong> <cfoutput>#alt#</cfoutput><br />
    Code (markup):
    That gives me the first instance of alt="" that it comes across. What I need to do is loop it to return all instances of alt="" that it finds.

    Any help?

    Thanks in advance.
     
    simplymatt, Oct 29, 2010 IP
  2. simplymatt

    simplymatt Guest

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Additionally, I have found that:

    <cfset result = reMatch("<img[^>]+>", Cfhttp.FileContent)>
    <cfdump var="#result#">
    HTML:
    will give me all the <img> from the page. However, I can't use <cfoutput> in place of <cfdump> as it is giving me an error.

    So close . . .
     
    simplymatt, Oct 29, 2010 IP
  3. cfStarlight

    cfStarlight Peon

    Messages:
    398
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Cfoutput only outputs simple objects. reMatch returns an array (complex object). Loop through the array and output each item individually.

    <cfoutput>
    <cfloop array="#yourArray#" index="elem">
    #elem# <br>
    </cfloop>
    </cfoutput>
     
    cfStarlight, Oct 29, 2010 IP