EasyCFM.COM ColdFusion Forums / Tutorial Requests! / Need some "MID(" magic...

   Reply to Discussion | New Discussion << previous || next >> 
Posted By Discussion Topic: Need some "MID(" magic...

book mark this topic Printer-friendly Version  send this discussion to a friend  new posts last

gmilby
11-08-2007 @ 8:50 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 281
Joined: Nov 2007

i'm fixing a database blunder, and need to basically
take a string like this, "images/filename.jpg" and truncate the 'images/' - mid( seems like the answer except every filename is a different length... is there a way to make it just remove all characters?
(i've tried trim, left, right and split in javascript)... all shot down. split came close, but couldn't get the javascript variable to be brought into the cfml code...
any help?
Tia,
Greg

=:All Hail, er - i mean "oh hell...":=

kicker
11-08-2007 @ 10:34 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Moderator
Posts: 717
Joined: Oct 2004

You will have to set it up with your own variables, and probably loop over if you have a mass amount you need to switch, but this should get you started and well underway.

<cfset myString = "images/myfilename.jpg">
<cfset myNumber = find("/",myString,1)>
<cfset myFolder = left(myString,myNumber)>
<cfset newString = replace(myString,myFolder," ","ALL")>
<cfoutput>#newString#</cfoutput>



Craig
Clearcg.com

gmilby
11-08-2007 @ 10:58 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 281
Joined: Nov 2007

when i was trying to approach the problem, i was trying to solve it like this - only i kept getting shut down at every turn.  Ron (from easycfm) found a way around this - so simple it left me speechless...
#listLast(myText,'/')#

i setup my query - looped through the query and set each up with the listLast and updated each field where id=#id# and it took 5 mins... wish i had asked sooner ;-)

Thank you kicker for taking the time to offer a suggestion.

=:All Hail, er - i mean "oh hell...":=


Website Designed and Developed by Pablo Varando.