<p>I'm trying to write a regex that will parse out the <strong>directory and filename</strong> of a fully qualified path using matching groups.</p>

<p>so...</p>

<pre><code>/var/log/xyz/10032008.log
</code></pre>

<p>would recognize <code>group 1 to be "/var/log/xyz"</code> and <code>group 2 to be "10032008.log"</code></p>

<p>Seems simple but I can't get the matching groups to work for the life of me.</p>

<p>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.</p>

What language? and why use regex for this simple task?
If you
must
:
```
```
^(.*)/([^/]*)$
```
```
gives you the two parts you wanted. You might need to quote the parentheses:
```
```
^\(.*\)/\([^/]*\)$
```
```
depending on your preferred language syntax.
But I suggest you just use your language's string search function that finds the last "/" character, and split the string on that index.