Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parsing the last "\"

Status
Not open for further replies.

IS300

MIS
Oct 29, 2003
121
CA
I would like to get the directory and the filename of the entire file path when a user enters it into a form.

So, if the filename is "T:\My Directory\Subdirectory\file\My file.doc",

I want to extract both parts, "T:\My Directory\Subdirectory\file\" and "file.doc" and put them in two different database fields

I don't know too much about string manipulation in ASP.

Thanks,
 
Try the inStrRev function. It will find the LAST occurrence of a string within a string:
Code:
InStrRev(string1, string2[, start[, compare]])


Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
If you are using VBScript for your ASP then the functions you need are InStr() or, even better, InStrRev() to find the position of the final slash... Left() to pull everything up to that positon and Mid() to pull everything from that position to the end... or you could just use Mid() for both.
 
You are wanting, InStrRev(),Left(), Right() functions...

example:
blah=Right(strpath,InStrRev(strpath,"\") ->gives you file.doc

play with those functions...

-DNG
 
All the suggestions were helpful.

Thanks a bunch!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top