# Dirname

> [Regular expression][regexp] to capture a path [dirname][dirname].


<section class="usage">

## Usage

``` javascript
var RE_DIRNAME = require( '@stdlib/regexp/dirname' );
```

#### RE_DIRNAME

[Regular expression][regexp] to capture a path [dirname][dirname].


#### RE_DIRNAME.posix

[Regular expression][@stdlib/regexp/dirname-posix] to capture a [POSIX][posix] path dirname. 

``` javascript
var dir = RE_DIRNAME.posix.exec( '/foo/bar/index.js' )[ 1 ];
// returns '/foo/bar'
```


#### RE_DIRNAME.win32

[Regular expression][@stdlib/regexp/dirname-windows] to capture a Windows path dirname. 

``` javascript
var dir = RE_DIRNAME.win32.exec( 'C:\\foo\\bar\\index.js' )[ 1 ];
// returns 'C:\\foo\\bar'
```

</section>

<!-- /.usage -->


<section class="notes">

## Notes

* The main exported [regular expression][regexp] is [platform][@stdlib/assert/is-windows]-dependent. If the current process is running on Windows, `re === re.win32`; otherwise, `re === re.posix`.

</section>

<!-- /.notes -->


<section class="examples">

## Examples

``` javascript
var RE_DIRNAME = require( '@stdlib/regexp/dirname' );

var dir;

// Assuming a POSIX platform...
dir = RE_DIRNAME.exec( '/foo/bar/index.js' )[ 1 ];
// returns '/foo/bar'

dir = RE_DIRNAME.posix.exec( '/foo/bar/home.html' )[ 1 ];
// returns '/foo/bar'

dir = RE_DIRNAME.win32.exec( 'C:\\foo\\bar\\home.html' )[ 1 ];
// returns 'C:\\foo\\bar'
```

</section>

<!-- /.examples -->


<section class="links">

[regexp]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
[dirname]: https://en.wikipedia.org/wiki/Dirname
[posix]: https://en.wikipedia.org/wiki/POSIX
[@stdlib/assert/is-windows]: https://github.com/stdlib-js/stdlib
[@stdlib/regexp/dirname-posix]: https://github.com/stdlib-js/stdlib
[@stdlib/regexp/dirname-windows]: https://github.com/stdlib-js/stdlib

</section>

<!-- /.links -->
