I'm trying to write a regex that will parse out the directory and filename of a fully qualified path using matching groups.
so...
/var/log/xyz/10032008.log
would recognize group 1 to be "/var/log/xyz"
and group 2 to be "10032008.log"
Seems simple but I can't get the matching groups to work for the life of me.
NOTE: As pointed out by some of the respondents this is probably not a good use of regular expressions. Generally I'd prefer to use the file API of the language I was using. What I'm actually trying to do is a little more complicated than this but would have been much more difficult to explain, so I chose a domain that everyone would be familiar with in order to most succinctly describe the root problem.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…