How could I design a RegEx script which would remove a filename from a path? The trick is, the paths have all sorts of wrenches to throw into the works.
Paths can consist of:
1: "Folder1/Folder2/Folder3.1234/folder4.5678/ApplesandOranges.txt","MoreInfo","EvenMoreInfo"
2: "Folder1/Folder2/Folder3.1234/folder4.91011/","MoreInfo","EvenMoreInfo"
or even
3: "Folder1/Folder2/Folder3.1234/folder4.5678/ApplesandOranges.zip?CatsAndDogs.txt","MoreInfo","EvenMoreInfo"
In cases 1 and 3, I'd like to end up with:
Folder1/Folder2/Folder3.1234/folder4.5678/
though, it would be acceptable for the second to return as
Folder1/Folder2/Folder3.1234/folder4.5678/ApplesandOranges.zip
though not preferred.
In case 2, it'd just skip that line entirely as there is no filename.
Any suggestions?
Using standard RegEx via a text editor. No java use and such.
Note: The path is just an example. There could be 50 folders. It's not a mere 4 folders all of the time
s/.*\/(.*)/\1/
? – Swiss