Skip to content

Instantly share code, notes, and snippets.

@caged caged/postgres-regex.sql
Last active Dec 26, 2015

What would you like to do?
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;

This comment has been minimized.

Copy link
Owner Author

caged commented Dec 26, 2015

Expected results:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.