Trimming a string after last instance of / character

2004-03-02 Thread Richard Crawford
Given a string that contains a directory name (e.g., 
/var/www/html/files/classes/admin), what is the best way to trim all 
of the characters off the last instance of the / character?

-- 
Richard S. Crawford
Programmer III,
UC Davis Extension Distance Learning Group (http://unexdlc.ucdavis.edu)
(916)327-7793 / [EMAIL PROTECTED]
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




Re: Trimming a string after last instance of / character

2004-03-02 Thread Ben Doom
Treat the string like a slash-delimited list, and use the appropriate 
function (someone borrowed my cf reference, sorry) to delete the last 
item.Something like (but probably not actually)

listdeleteat(string, listlen(string, '/'), '/');

--Ben Doom

Richard Crawford wrote:

 Given a string that contains a directory name (e.g.,
 /var/www/html/files/classes/admin), what is the best way to trim all
 of the characters off the last instance of the / character?
 
 -- 
 Richard S. Crawford
 Programmer III,
 UC Davis Extension Distance Learning Group (http://unexdlc.ucdavis.edu)
 (916)327-7793 / [EMAIL PROTECTED]

 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




RE: Trimming a string after last instance of / character

2004-03-02 Thread Stevenson, Christopher
 Given a string that contains a directory name (e.g., 
 /var/www/html/files/classes/admin), what is the best
 way to trim all of the characters off the last instance
 of the / character?

 listdeleteat(string, listlen(string, '/'), '/');

Or

getDirectoryFromPath(string)

Regards,
Chris Stevenson
Web Administrator
AIHW
[EMAIL PROTECTED]
61 2 6244 1029 P
61 2 6244 1299 F
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




Re: Trimming a string after last instance of / character

2004-03-02 Thread Richard Crawford
Stevenson, Christopher wrote:

Given a string that contains a directory name (e.g., 
/var/www/html/files/classes/admin), what is the best
way to trim all of the characters off the last instance
of the / character?
 
 
listdeleteat(string, listlen(string, '/'), '/');
 
 
 Or
 
 getDirectoryFromPath(string)

That's very close to what I need.I need to ascend one directory level 
and then descend into a different directory.

From:

/directory/subdirectory/path1

to:

/directory/subdirectory/path2

-- 
Richard S. Crawford
Programmer III,
UC Davis Extension Distance Learning Group (http://unexdlc.ucdavis.edu)
(916)327-7793 / [EMAIL PROTECTED]
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




Re: Trimming a string after last instance of / character - RESOLVED

2004-03-02 Thread Richard Crawford
This is what I used:

cfset pathDir=#GetDirectoryFromPath(CGI.PATH_TRANSLATED)#
cfset trimpathDir=listdeleteat(#pathDir#, listlen(#pathDir#,'/'), '/') 
 /

Adding the final / at the end turned out to be key.

-- 
Richard S. Crawford
Programmer III,
UC Davis Extension Distance Learning Group (http://unexdlc.ucdavis.edu)
(916)327-7793 / [EMAIL PROTECTED]
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]