theniteowl
Programmer
Hi All,
this should be fairly easy.
I need to drop the filename off the end of a path but cannot rely on there always being a filename so it should only drop text at the end if there is an extension to the text.
For example
/myfolder/subfolder/myfile.htm
should get stripped to
/myfolder/subfolder
but
/myfolder/subfolder/folder2
should not get stripped because it has no extension.
I guess it's a case of if there is a period then it should clip the string at the last slash?
Anyone good with regular expressions?
I could explode the path then build a new string but it just seems inefficient where I think it can be done in one or two lines without looping.
Thanks.
At my age I still learn something new every day, but I forget two others.
this should be fairly easy.
I need to drop the filename off the end of a path but cannot rely on there always being a filename so it should only drop text at the end if there is an extension to the text.
For example
/myfolder/subfolder/myfile.htm
should get stripped to
/myfolder/subfolder
but
/myfolder/subfolder/folder2
should not get stripped because it has no extension.
I guess it's a case of if there is a period then it should clip the string at the last slash?
Anyone good with regular expressions?
I could explode the path then build a new string but it just seems inefficient where I think it can be done in one or two lines without looping.
Thanks.
At my age I still learn something new every day, but I forget two others.