Reputation: 577
can anyone give me a few examples of getting the path from a full path..e.g
c:\aaa\bbb\c cc\file.exe
to
c:\aaa\bbb\c cc\
more than 1 example method would be cool but must be regex only, this is for a language called ICI but it has similar regex to perl and other such language this is why I need a few examples, atleast one will work better than the other and i can modify it.
thanks!
Upvotes: 0
Views: 1086
Reputation: 1148
Here is a basic example of an inverse regex (finds the filename). Just use the substring before the start to get the path.
[\w]*[.][\w]*$
And the path only:
.*[\\]
Upvotes: 1
Reputation: 624
Group (1) will give you c:\aaa\bbb\c cc
with this
(.*)\\\w*\.
You can use
(.*\\)\w*\.
if you want to capture the last \
Upvotes: 1