Skip to content

Latest commit

 

History

History

basename

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Basename

Regular expression to capture the last part of a path.

Usage

var RE_BASENAME = require( '@stdlib/regexp/basename' );

RE_BASENAME

Regular expression to capture the last part of a path.

RE_BASENAME.posix

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'

RE_BASENAME.win32

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'

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_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'