Quantcast
Channel: RobVolk.com » Javascript
Viewing all articles
Browse latest Browse all 3

Get a Filename from a Path in Javascript

$
0
0

Here’s a quick Javascript function that will parse the filename from a path using regex.  It looks for any letter or digit, hyphen, or underscore followed by a dot (.) followed by a letters or numbers for the extension.

function getFileName(path) {
    return path.match(/[-_\w]+[.][\w]+$/i)[0];
}

The post Get a Filename from a Path in Javascript appeared first on RobVolk.com.


Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles



Latest Images