Home > Forum > Actions > Extracting Regex‑Matched Phrases from Text

Extracting Regex‑Matched Phrases from Text
0

Hi everyone,
I would like to extract all phrases from a text (e.g., an email body) that match a specific format defined by a regular expression.

Is it possible to achieve this using WEBCON’s built-in functions?

MVP

Hi Tomasz,
You can try use the SQL command and REGEXP_SUBSTR (SQL Server 2025 required).

In older versions of SQL, you can use PATINDEX e.g:
DECLARE @text NVARCHAR(200) = 'Company details: NIP 1234567890, ul. Testowa 1, Warsaw';
SELECT SUBSTRING(@text, PATINDEX('%[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]%', @text), 10) AS NIP;

Regards,
Jacek