Regular expression to capture the last part of a path.
var RE_BASENAME = require( '@stdlib/regexp/basename' );
Regular expression to capture the last part of a path.
Regular expression to capture the last part of a POSIX path.
var base = RE_BASENAME.posix.exec( '/foo/bar/index.js' )[ 1 ];
// returns 'index.js'
Regular expression to capture the last part of a Windows path.
var base = RE_BASENAME.win32.exec( 'C:\\foo\\bar\\index.js' )[ 1 ];
// returns 'index.js'
- The main exported regular expression is platform-dependent. If the current process is running on Windows,
RE === RE.win32
; otherwise,RE === RE.posix
.
var RE_BASENAME = require( '@stdlib/regexp/basename' );
// Assuming a POSIX platform...
var base = RE_BASENAME.exec( '/foo/bar/index.js' )[ 1 ];
// returns 'index.js'
base = RE_BASENAME.posix.exec( '/foo/bar/home.html' )[ 1 ];
// returns 'home.html'
base = RE_BASENAME.win32.exec( 'C:\\foo\\bar\\home.html' )[ 1 ];
// returns 'home.html'