I have a path like this C:\Users\Administrator\Desktop\Photos-or\3-PRO\3-1-CR\CR-RESTS\LES-COQS\1920x500
and I'd like a regex to match the grandparent folder which, in this case, is LES-COQS
.
I've tried:
echo "C:\Users\Administrator\Desktop\Photos-or\3-PRO\3-1-CR\CR-RESTS\LES-COQS\1920x500" | grep -i "[a-zA-Z0-9-]*\\\[0-9a-z]*$"
Should I use a lookahead/lookbehind ? Or is there a simpler way ?
Thanks
/
separated on Unix. Assuming you mean a MS-DOS path, I don't seeLESCOQS
in it, onlyLES-COQS
which would be the directory containing the1920x500
file, not its grandparent by any meaning of grandparent. Also, it's not clear what you mean by matching here. What's the output you're expecting?1920x500
is itself a directory and thus a "parent" of some unspecified file. Louis, is that right?I need a pure regex solution
- so this is homework, right? Otherwise you wouldn't use a regexp for this.