Skip to content

Instantly share code, notes, and snippets.

@MatthewDaniels
Last active October 12, 2016 01:31
Show Gist options
  • Save MatthewDaniels/f0c969ce9107e6da4ba2cfa209b8c03b to your computer and use it in GitHub Desktop.
Save MatthewDaniels/f0c969ce9107e6da4ba2cfa209b8c03b to your computer and use it in GitHub Desktop.
Google App Script to reverse a url
/**
* Reverses the input url.
*
* EG: if the url is www.google.com, the result will be com.google.www - this is useful for sorting a sheet
*
* @param {string} input The url to reverse.
* @return The url reversed.
* @customfunction
*/
function REVERSEURL(string) {
if (typeof string != 'string') {
return null;
}
return string.split('.').reverse().join('.');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment