4 Replies Latest reply on Jun 1, 2007 8:17 AM by Flashhhgordon

    Extract path from SRC in a IMG tag

    Flashhhgordon
      I have a query which outputs a bunch of text with pictures in it. I'm trying to get the path from the SRC tag.

      <IMG height=250 alt="" hspace=0 src="/intranet/images/files/first.jpg" width=350 border=0>

      After the regex i have to get this: /intranet/images/files/first.jpg but my code throws a error constantly.

      Any thoughts?

      Thank you.

      Flashhgordon


        • 1. Re: Extract path from SRC in a IMG tag
          insuractive Level 3
          What kind of error are you getting?

          does this work any better:

          ReReplaceNoCase(qGetText.EZineBody, '(<IMG [^>]* src=")([^"]+)(" [^>]*>)', \2)
          • 2. Extract path from SRC in a IMG tag
            Flashhhgordon Level 1
            I'm getting this error:

            Missing argument name.
            When using named parameters to a function, every parameter must have a name.
            The CFML compiler was processing:

            an expression beginning with "rereplacenocase", on line 9, column 19.This message is usually caused by a problem in the expressions structure.
            a cfset tag beginning on line 9, column 2.


            The error occurred in D:\websites\Intranet\test.cfm: line 9

            7 :
            8 :
            9 : <cfset varImage = rereplacenocase(qGetText.EZineBody, '<img[^>;]*>(.+)', \1)>
            10 :
            11 : <cfoutput query="qGetText">#EZineBody#</cfoutput>




            I tried your code but unfortunately it throws an error too (see below):

            Missing argument name.
            When using named parameters to a function, every parameter must have a name.
            The CFML compiler was processing:

            an expression beginning with "ReReplaceNoCase", on line 9, column 19.This message is usually caused by a problem in the expressions structure.
            a cfset tag beginning on line 9, column 2.


            The error occurred in D:\websites\Intranet\test.cfm: line 9

            7 :
            8 :
            9 : <cfset varImage = ReReplaceNoCase(qGetText.EZineBody, '(<IMG [^>]* src=")([^"]+)(" [^>]*>)', \2)>
            10 :
            11 : <cfoutput query="qGetText">#EZineBody#</cfoutput>





            • 3. Re: Extract path from SRC in a IMG tag
              insuractive Level 3
              Have you tried adding in the scope parameter?

              What happens when you try this?
              <cfset varImage = ReReplaceNoCase(qGetText.EZineBody, '(<IMG [^>]* src=")([^"]+)(" [^>]*>)', "\2", "all")>

              • 4. Re: Extract path from SRC in a IMG tag
                Flashhhgordon Level 1
                Works like a charm Michael... Thank you..