Last active
August 29, 2015 13:56
-
-
Save pstef/9238780 to your computer and use it in GitHub Desktop.
<lluad> Is there a tidier way to get the last two components of a hostname than (regexp_matches(foo, '\.([^.]+\.[^.]+)$'))[1] ? It works, but kinda offends even me. It's only going to be used on hostnames, so I don't really care what it does to non-hostname input.
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
SELECT array_to_string(a[array_upper(a, 1)-1:array_upper(a, 1)], '.') | |
FROM string_to_array('gist.github.com', '.') a |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment