Skip to content

Instantly share code, notes, and snippets.

@rwz
Created October 4, 2012 04:52
Show Gist options
  • Save rwz/3831542 to your computer and use it in GitHub Desktop.
Save rwz/3831542 to your computer and use it in GitHub Desktop.
str = "some file name.with dots.html.markdown"
extensions = str[/(?:\.\w+)+$/]
extensions ? [ str.sub(extensions, ''), extensions[1..-1].split('.') ] : [ str ]
@rwz
Copy link
Author

rwz commented Oct 4, 2012

Works with "a.b c.a" as well, producing ["a.b c", ["a"]]

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