Extract the first character of each string part separated by the '-'. There can be an unknown number of potential parts.
✓ Published0🌍 Public
CCaged
Last edited Dec 26, 2015
Created on Dec 26, 2015
This example demonstrates how to extract the first character of each string segment separated by hyphens, regardless of the number of segments, and concatenate them into a single output. It shows a concise SQL pattern for parsing structured text data. The query uses PostgreSQL’s `regexp_matches` function with a global flag to find all alphanumeric characters, then aggregates the results with `array_agg` and converts the array to a string via `array_to_string`. The source data, ‘Letter-1-2’, is processed to yield the abbreviated result, highlighting the reusable regex and array functions for dynamic text parsing.
AI-generated description