the input is C:\test\deva\tcl\newfiles\aug.txt
the output should be “test” “deva” “tcl” “newfiles”
“aug.txt” files or anyother “.txt” files at the end of the string should not be printed.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Reverting back to my original solution and adding some bits…
Assuming this is a filepath not a random string that happens to need to be split \
File split does almost what you want, it returns the path split up as a list . you also want to use lrange to select everything but the volume i.e something like (untested)
so you don’t have c:\ which should be the first element in the list returned by file split
Additionally you may want to use file dirname first if there is any chance you will get directory path instead of a filename e.g. same caveats re testing