Skip to content

Files

Latest commit

3785123 · Dec 7, 2016

History

History

dirname

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Jun 1, 2016
Oct 29, 2016
Oct 29, 2016
Dec 5, 2016
Dec 7, 2016

README.md

dirname

Regular expression to capture a path dirname.

Usage

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

RE_DIRNAME

Regular expression to capture a path dirname.

var dir;

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

// On a Windows platform...
dir = RE_DIRNAME.exec( 'C:\\foo\\bar\\index.js' )[ 1 ];
// returns 'C:\\foo\\bar'

RE_DIRNAME.posix

Regular expression to capture a POSIX path dirname.

RE_DIRNAME.win32

Regular expression to capture a Windows path dirname.

Notes

  • The main exported regular expression is platform-dependent. If the current process is running on Windows, re === re.win32; otherwise, re === re.posix.

Examples

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'