function basename(path) {
return path.split("https://stackoverflow.com/").reverse()[0];
}
Breaks up the path into component directories and filename then returns the last piece (the filename) which is the last element of the array.
More Related Contents:
- Count the recurrence of a word
- Repeat a string in JavaScript a number of times
- How to get character array from a string?
- Check if a JavaScript string is a URL
- How to check if a string contains text from an array of substrings in JavaScript?
- How to remove text from a string?
- How to replace all dots in a string using JavaScript
- How to convert a string to an integer in JavaScript?
- How can I convert a comma-separated string to an array?
- How to set object property (of object property of..) given its string name in JavaScript?
- Shorten string without cutting words in JavaScript
- How to find indices of all occurrences of one string in another in JavaScript?
- How can I insert a character after every n characters in javascript?
- How can I remove a character from a string using JavaScript?
- Javascript – return string between square brackets
- Case insensitive string replacement in JavaScript?
- JavaScript string with new line – but not using \n
- Remove characters from a string [duplicate]
- is the + operator less performant than StringBuffer.append()
- How to extract base URL from a string in JavaScript?
- Get the string representation of a DOM node
- How to convert text to binary code in JavaScript?
- How to parse JSON string in Typescript
- How do I escape a string inside JavaScript code inside an onClick handler?
- Convert javascript array to string
- Commas messing with number input in Javascript
- Are double and single quotes interchangeable in JavaScript?
- Use RegExp to match a parenthetical number then increment it
- How to add spaces between every character in a string?
- javascript – Convert array to string while preserving brackets