I think the first solution without the regexp works a bit better, but
take your pick:

<cfset mystring="/web/path/to/myfile.jpg JPEG 1280x1024 DirectClass
8-bit 95kb 0.3u 0:01">

<cfset dimensions=listGetAt(mystring,3," ")>
<cfset width=listGetAt(dimensions,1,"x")>
<cfset height=listGetAt(dimensions,2,"x")>

<cfoutput>width: #width#, height: #height#<br></cfoutput>

<cfset findWidth=reFind("[0-9]+",mystring,0,"true")>
<cfset width=mid(mystring, findWidth.pos[1], findWidth.len[1])>
<cfset findHeight=reFind("[0-9]+",mystring,findWidth.pos[1],"true")>
<cfset height=mid(mystring, findHeight.pos[1], findHeight.len[1])>

<cfoutput>width: #width#, height: #height#<br></cfoutput>

Only problem with both is there is no error checking for the case where
no width/height is set, and also the regexp would return the wrong
result if the filename had numbers in it.

Hth,

James




-----Original Message-----
From: Willy Ray [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, 10 October 2002 19:55
To: CF-Talk
Subject: SOT: RegEx


Ok, I have a string that looks like this:

/web/path/to/myfile.jpg JPEG 1280x1024 DirectClass 8-bit 95kb 0.3u 0:01

It's an imagemagic identification of a file that my user is uploading.
myfile.jpg is CFFILE.clientfile.

I need to go through this thing and get the 1280x1024 out.  I could come
up with a way to do this w/o regular expressions, but it wouldn't be as
flexible as I'd like it to be.

I've tried this:


        <cfset location = REFind("/d+x/d+", mystring)>

And this:

        <cfset start = REFind("[/d+]x[/d+]", mystring)>

Doesn't seem to work.  Any ideas?



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Reply via email to