Created
July 12, 2021 21:09
-
-
Save DerexScript/b4b2bb7e9faeddfaef320cf2a5fdf015 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function str_replace_last(search, replace, str){ | |
let pos = str.lastIndexOf('webp'); | |
let search_length; | |
if(pos != -1){ | |
search_length = search.length; | |
str = str.substring(0, pos)+replace+str.substring(pos+search_length); | |
} | |
return str; | |
} | |
str_replace_last("webp", "jpg", "22708867webp360e747bwebp444651.webp"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment