On Jan 8, 2008 9:30 AM, Che Vilnonis <[EMAIL PROTECTED]> wrote: > I was reading a blog post by Rupesh Kumar about searching through arrays: > https://www.blogger.com/comment.g?blogID=19056005&postID=116861460940707835 > > He speaks of how you can use the underlying java APIs for searching. His > examples worked find for me, but when I create an array with CF8s new > reMatchNoCase function, I can't get his code to work. Any idea why? Is the > reMatchNoCase array not a "real" array? See my simple code below. The result > should not be zero. > > > <cfhttp url="http://ww2.collectorcartrader.com/details.php?adId=90177579" > method="get"> > > <cfset images = reMatchNoCase("<img([^>]*[^/]?)>",cfhttp.FileContent)> > <cfset temp = images.indexof("_1thumb.jpg") + 1> > > <cfoutput>#temp#</cfoutput>
try dumping your "images" array, and you'll see that you do have an array of the images. so yes, it is a "real" array. indexOf() returns the element in the array that contains the string searched for. NOT the substring. your array doesn't have an element "_1thumb.jpg", so yes... the output of #temp# -should- be 0. your code is outputting exactly what you're asking it to output. there may very well be a more elegant way, but to find a substring in an array of strings, i'm afraid you'd have to loop over the array and testing each element (<cfif ... CONTAINS "_1thumb.jpg" ...>) -- "Scientists tell us that the fastest animal on earth, with a top speed of 120 feet per second, is a cow that has been dropped out of a helicopter." - Dave Barry ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| 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:296157 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

