> <cfset imageLink = REReplaceNoCase(cfhttp.fileContent,
> "<img[^>]+([a-z0-9_]\.(?:jpg|jpeg|gif|png))[^>]*>", "", "ONE")>
In addition to Ben's comment, it doesn't look like you're finding the
beginning of the src attribute, see:
<img[^>]+ and then straight into the regex for the url ... so there's no
mention of src=" ... there's also no allowance for the protocol (https?://)
and the : in (?:jpg| seems erroneous...
I might suggest a slightly different "tac" ... instead of trying to get
it with one expression, how about this?
<cfset img = rereplacenocase(cfhttp.filecontent,
"^.*?(<img[^>]+>).*$","\1")>
<cfset img = rereplace(img,"[^/]>","/>")>
<cfset img = xmlparse(img) />
<cfset img = img.img.xmlAttributes.src>
Usually an image tag doesn't contain any characters that aren't xml safe,
since it's just got the src (no url parameters usually), class, style
and potentially an alt or title tag. It's really the alt or title tag
that might potentially have non-xml safe characters, but still not very
often. The 2nd rereplace checks to see if the image has an xml closing
and if not then it closes it so that the xmlparse() will work properly.
Of course, if you don't want to do the xml thing, once you have the tag
by itself, then it's a lot easier to just get the src attribute via
regex,i.e.
<cfset img = rereplace(img,"^.*src="([^"]+)".*$","\1")>
Although that runs some other potential risks of getting content from a
site that's using xml where the author used single-quotes instead of
doublequotes (minor change to the above regex I admit). I'm just saying,
6 of 1, 1/2-doz of the other there are a number of potential points of
failure either way.
hth,
ike
--
s. isaac dealey ^ new epoch
isn't it time for a change?
ph: 503.236.3691
http://onTap.riaforge.org
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to
date
Get the Free Trial
http://ad.doubleclick.net/clk;160198600;22374440;w
Archive:
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:295227
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4