Skip to content

Instantly share code, notes, and snippets.

@prcaen
Created November 14, 2011 20:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prcaen/1365016 to your computer and use it in GitHub Desktop.
Save prcaen/1365016 to your computer and use it in GitHub Desktop.
[JS] - strrchr
function strrchr (haystack, needle) {
var pos = 0;
if (typeof needle !== 'string')
needle = String.fromCharCode(parseInt(needle, 10));
needle = needle.charAt(0);
pos = haystack.lastIndexOf(needle);
if (pos === -1)
return false;
return haystack.substr(pos);
}
@Loudrama
Copy link

ghnghng

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment