Not sure what would perform faster but this would be more reliable when it comes to extension like .jpeg
or .html
x.replace(/\.[^/.]+$/, "")
More Related Contents:
- What is the difference between String.slice and String.substring?
- How to grab substring before a specified character in JavaScript?
- How can I replace a regex substring match in Javascript?
- Get value of a string after last slash in JavaScript
- How to check whether a string contains a substring in JavaScript?
- How to replace all occurrences of a string in JavaScript
- Replace multiple strings with multiple other strings
- Why doesn’t indexOf work on an array IE8?
- How to replace all occurrences of a string in JavaScript
- What is the difference between substr and substring?
- Why Array.indexOf doesn’t find identical looking objects
- Is there a version of JavaScript’s String.indexOf() that allows for regular expressions?
- How do I check if string contains substring? [duplicate]
- Remove whitespace and line breaks between HTML elements using jQuery
- Replace a Regex capture group with uppercase in Javascript
- How to replace last occurrence of characters in a string using javascript
- How do I replace all occurrences of a string in JavaScript?
- How can I perform a str_replace in JavaScript, replacing text in JavaScript?
- Cutting a string at nth occurrence of a character
- JavaScript – Replace all commas in a string [duplicate]
- Javascript 2d array indexOf
- JavaScript text between double quotes
- Reformat string containing date with Javascript
- Javascript oddness with array of objects and indexOf
- `string.replace` doesn’t change the variable [duplicate]
- How do I replace all occurrences of “/” in a string with “_” in JavaScript?
- Replace spaces with dashes and make all letters lower-case
- How to replace curly quotation marks in a string using Javascript?
- window.location.indexOf not working in Javascript
- JavaScript: replace last occurrence of text in a string