Skip to content

Instantly share code, notes, and snippets.

@caged
Last active December 26, 2015 21:52
Show Gist options
  • Save caged/7f7c3a7f195b588c67f5 to your computer and use it in GitHub Desktop.
Save caged/7f7c3a7f195b588c67f5 to your computer and use it in GitHub Desktop.
Extract the first character of each string part separated by the '-'. There can be an unknown number of potential parts.
select array_to_string(array_agg(i), '') from
(select (regexp_matches('Letter-1-2', '[A-Z0-9]', 'g'))[1] i) t;
@caged
Copy link
Author

caged commented Dec 26, 2015

Expected results:

 array_to_string
-----------------
 L12

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