What does [^>]*? Mean exactly? I seem to be using something similar in my old code but can't remember what it means.
I know perl regular expressions and this doesn't seem to make sense. [^>] means expression starting with a > then * is a modifier meaning zero or more and ? is a modifier meaning 0 or 1 times. I don't understand how that is legal regex. Is CF regex that much different then perl? Russ -----Original Message----- From: S. Isaac Dealey [mailto:[EMAIL PROTECTED]] Sent: Tuesday, September 03, 2002 10:34 AM To: CF-Talk Subject: Re: Regular Expressions > Posted this yesterday, but it never made it on the list. > I'm a little rusty on my regular expressions. Can somebody help me out > with these two that I'm having problems with. > The first is > <cfset st1 = REFindNoCase('Our New Price: <font > color=".?AA0000">\$([0-9\.]+)<BR></font>',testString,1,"TRUE")> > <cfset price=Mid(testString,st1.pos[2],st1.len[2])> > <cfoutput>#price#</cfoutput> > It's supposed to match > Our New Price: <font color="#AA0000">$84.00<BR></font> > > It works fine, but I think the regex could be better? > Try this <cfset price = REREplaceNoCase(testString,'Our New Price: <font [^>]*?>\$([\.,0-9]+?)',"\1")> <cfoutput>#price#</cfoutput> This will ignore any attributes within the font tag so you don't have to worry about them changing... It also sets your price with a single <cfset> rather than 2 > The second one I can't get to match > > <cfset st1 = REFindNoCase('<IMG SRC="([.]*)" vspace=0 border=0 > ALT="[A-Za-z ]+" HEIGHT="125" WIDTH="100">',testString,1,"TRUE")> > <cfset src=Mid(testString,st1.pos[2],st1.len[2])> > <cfoutput>#src#</cfoutput> > > Is supposed to match > > <td width="1%"><IMG > SRC="http://a1204.g.akamai.net/7/1204/1401/02050212011/images.barnesandn > oble.com/images/5070000/5077366.gif" vspace=0 border=0 ALT="Operating > Systems" HEIGHT="125" WIDTH="100"></td> > > and return the URL. Depends on your requirements... Do you need the image specifically which has the ALT attribute of "Operating Systems"? If so, you might try this: <cfset temp = REREplaceNoCase(testString,'(<img [^>]*?alt="Operating Systems"[^>]*?>)',"\1")> <cfset src = REReplaceNoCase(temp,'href="([^"]+?)"',"\1")> The first regex gets your image tag, then the 2nd regex gets the src attribute out of that. This should work even if they move the alt tag around... hth Isaac Dealey Certified Advanced ColdFusion 5 Developer www.turnkey.to 954-776-0046 ______________________________________________________________________ Signup for the Fusion Authority news alert and keep up with the latest news in ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/[email protected]/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

