{"id":6142,"date":"2025-11-18T08:00:10","date_gmt":"2025-11-18T16:00:10","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/azure-sql\/?p=6142"},"modified":"2025-11-17T10:08:14","modified_gmt":"2025-11-17T18:08:14","slug":"general-availability-announcement-regex-support-in-sql-server-2025-azure-sql","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/azure-sql\/general-availability-announcement-regex-support-in-sql-server-2025-azure-sql\/","title":{"rendered":"General Availability Announcement: Regex Support in SQL Server 2025 &amp; Azure SQL"},"content":{"rendered":"<div class=\"paragraph-in-scc-markdown-text ___1ngh792 ftgm304 f1iaxwol\" style=\"text-align: center\">\n<p><a href=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2025\/11\/Picture1.webp\"><img decoding=\"async\" class=\"aligncenter wp-image-6262 size-full\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2025\/11\/Picture1.webp\" alt=\"Picture1 image\" width=\"1153\" height=\"482\" srcset=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2025\/11\/Picture1.webp 1153w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2025\/11\/Picture1-300x125.webp 300w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2025\/11\/Picture1-1024x428.webp 1024w, https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2025\/11\/Picture1-768x321.webp 768w\" sizes=\"(max-width: 1153px) 100vw, 1153px\" \/><\/a><\/p>\n<p style=\"text-align: left\">We\u2019re excited to announce the <strong>General Availability (GA)<\/strong> of <strong>native Regex support<\/strong> in <strong>SQL Server 2025<\/strong> and <strong>Azure SQL<\/strong> \u2014 a long-awaited capability that brings powerful pattern matching directly into T-SQL. This release marks a significant milestone in modernizing string operations and enabling advanced text processing scenarios natively within the database engine.<\/p>\n<\/div>\n<h2>What is Regex?<\/h2>\n<p>The other day, while building LEGO with my 3-year-old \u2014 an activity that\u2019s equal parts joy and chaos \u2014 I spent minutes digging for one tiny piece and thought, \u201c<em>If only Regex worked on LEGO.<\/em>\u201d<\/p>\n<p>That moment of playful frustration turned into a perfect metaphor.<\/p>\n<p>Think of your LEGO box as a pile of data \u2014 a colorful jumble of tiny pieces. Now imagine trying to find every little brick from a specific LEGO set your kid mixed into the pile. That\u2019s tricky \u2014 you\u2019d have to sift through each piece one by one.<\/p>\n<p>But what if you had a <em>smart filter<\/em> that instantly found exactly those pieces?<\/p>\n<p>That\u2019s what <strong>Regex<\/strong> (short for <strong>Regular Expressions<\/strong>) does for your data. It\u2019s a powerful pattern-matching tool that helps you search, extract, and transform text with precision.<\/p>\n<p>With <strong>Regex now natively supported in SQL Server 2025 and Azure SQL<\/strong>, this capability is built directly into T-SQL \u2014 no external languages or workarounds required.<\/p>\n<h2>What can Regex help you do?<\/h2>\n<div class=\"paragraph-in-scc-markdown-text ___1ngh792 ftgm304 f1iaxwol\">Regex can help you tackle a wide range of data challenges, including:<\/div>\n<ul>\n<li class=\"___ccc16d0 fje8fi8 f1ng9h0j f1bwykku f18jd3zf\"><strong>Enhancing data quality and accuracy<\/strong> by validating and correcting formats like phone numbers, email addresses, zip codes, and more.<\/li>\n<li class=\"___ccc16d0 fje8fi8 f1ng9h0j f1bwykku f18jd3zf\"><strong>Extracting valuable insights<\/strong> by identifying and grouping specific text patterns such as keywords, hashtags, or mentions.<\/li>\n<li class=\"___ccc16d0 fje8fi8 f1ng9h0j f1bwykku f18jd3zf\"><strong>Transforming and standardizing data<\/strong> by replacing, splitting, or joining text patterns \u2014 useful for handling abbreviations, acronyms, or synonyms.<\/li>\n<li class=\"___ccc16d0 fje8fi8 f1ng9h0j f1bwykku f18jd3zf\"><strong>Cleaning and optimizing data<\/strong> by removing unwanted patterns like extra whitespace, punctuation, or duplicates.<\/li>\n<\/ul>\n<h2>Meet the new Regex functions in T-SQL<\/h2>\n<p>SQL Server 2025 introduces <strong>seven new T-SQL Regex functions<\/strong>, grouped into two categories:\u00a0scalar functions (return a value per row) and table-valued functions (TVFs) (return a set of rows). Here\u2019s a quick overview:<\/p>\n<table style=\"border-collapse: collapse;width: 100%\">\n<tbody>\n<tr>\n<td style=\"width: 33.3333%\"><strong>Function<\/strong><\/td>\n<td style=\"width: 9.15513%\"><strong>Type<\/strong><\/td>\n<td style=\"width: 57.5115%\"><strong>Description<\/strong><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 33.3333%\">REGEXP_LIKE<\/td>\n<td style=\"width: 9.15513%\">Scalar<\/td>\n<td style=\"width: 57.5115%\">Returns <code>TRUE<\/code> if the input string matches the Regex pattern<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 33.3333%\">REGEXP_COUNT<\/td>\n<td style=\"width: 9.15513%\">Scalar<\/td>\n<td style=\"width: 57.5115%\">\u00a0Counts the number of times a pattern occurs in a string<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 33.3333%\">REGEXP_INSTR<\/td>\n<td style=\"width: 9.15513%\">Scalar<\/td>\n<td style=\"width: 57.5115%\">\u00a0Returns the position of a pattern match within a string<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 33.3333%\">REGEXP_REPLACE<\/td>\n<td style=\"width: 9.15513%\">Scalar<\/td>\n<td style=\"width: 57.5115%\">Replaces substrings that match a pattern with a replacement string<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 33.3333%\">REGEXP_SUBSTR<\/td>\n<td style=\"width: 9.15513%\">Scalar<\/td>\n<td style=\"width: 57.5115%\">Extracts a substring that matches a pattern<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 33.3333%\">REGEXP_MATCHES<\/td>\n<td style=\"width: 9.15513%\">TVF<\/td>\n<td style=\"width: 57.5115%\">Returns a table of all matches including substrings and their positions<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 33.3333%\">REGEXP_SPLIT_TO_TABLE<\/td>\n<td style=\"width: 9.15513%\">TVF<\/td>\n<td style=\"width: 57.5115%\">Splits a string into rows using a Regex delimiter<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>These functions follow the <strong>POSIX standard<\/strong> and support most of the PCRE\/PCRE2 flavor of regular expression syntax, making them compatible with most modern Regex engines and tools.<\/p>\n<div class=\"paragraph-in-scc-markdown-text ___1ngh792 ftgm304 f1iaxwol\">They support common features like:<\/div>\n<ul>\n<li class=\"___ccc16d0 fje8fi8 f1ng9h0j f1bwykku f18jd3zf\">Character classes (<code>\\d<\/code>, <code>\\w<\/code>, etc.)<\/li>\n<li class=\"___ccc16d0 fje8fi8 f1ng9h0j f1bwykku f18jd3zf\">Quantifiers (<code>+<\/code>, <code>*<\/code>, <code>{n}<\/code>)<\/li>\n<li class=\"___ccc16d0 fje8fi8 f1ng9h0j f1bwykku f18jd3zf\">Alternation (<code>|<\/code>)<\/li>\n<li class=\"___ccc16d0 fje8fi8 f1ng9h0j f1bwykku f18jd3zf\">Capture groups (<code>(...)<\/code>)<\/li>\n<\/ul>\n<div class=\"paragraph-in-scc-markdown-text ___1ngh792 ftgm304 f1iaxwol\">You can also use <strong>Regex flags<\/strong> to modify behavior:<\/div>\n<ul>\n<li class=\"___ccc16d0 fje8fi8 f1ng9h0j f1bwykku f18jd3zf\"><code>'i'<\/code> \u2013 Case-insensitive matching<\/li>\n<li class=\"___ccc16d0 fje8fi8 f1ng9h0j f1bwykku f18jd3zf\"><code>'m'<\/code> \u2013 Multi-line mode (<code>^<\/code> and <code>$<\/code> match line boundaries)<\/li>\n<li class=\"___ccc16d0 fje8fi8 f1ng9h0j f1bwykku f18jd3zf\"><code>'s'<\/code> \u2013 Dot matches newline<\/li>\n<li class=\"___ccc16d0 fje8fi8 f1ng9h0j f1bwykku f18jd3zf\"><code>'c'<\/code> \u2013 Case-sensitive matching (default)<\/li>\n<\/ul>\n<p><div class=\"alert alert-primary\"><p class=\"alert-divider\"><i class=\"fabric-icon fabric-icon--Info\"><\/i><strong>Note<\/strong><\/p><strong>REGEXP_LIKE<\/strong>, <strong>REGEXP_MATCHES<\/strong> and <strong>REGEXP_SPLIT_TO_TABLE<\/strong> functions are available only under compatibility level 170 and above. If your database compatibility level is lower than 170, SQL Server can\u2019t find and run these functions. Other regular expression functions are available at all compatibility levels. You can check compatibility level in the <code>sys.databases<\/code> view or in database properties. You can change the compatibility level of a database with the following command:<\/p>\n<p><code>ALTER DATABASE [DatabaseName] SET COMPATIBILITY_LEVEL = 170;<\/code><\/div><\/p>\n<h2>Examples: Regex in Action<\/h2>\n<p>Let\u2019s explore how these functions solve tricky real-world data tasks that were hard to do in earlier SQL versions.<\/p>\n<h3><code>REGEXP_LIKE<\/code>: Data Validation \u2014 Keeping data in shape<\/h3>\n<div class=\"paragraph-in-scc-markdown-text ___1ngh792 ftgm304 f1iaxwol\">Validating formats like email addresses or phone numbers used to require multiple functions or external tools. With <code>REGEXP_LIKE<\/code>, it\u2019s now a concise query. For example, you can check whether an email contains valid characters before and after the <code>@<\/code>, followed by a domain with at least two letters like <code>.com<\/code>, <code>.org<\/code>, or <code>.co.in<\/code>.<\/div>\n<pre class=\"prettyprint language-sql\"><code class=\"language-sql\">SELECT [Name],\r\n       Email,\r\n       CASE WHEN REGEXP_LIKE (Email, '^[A-Za-z0-9._+]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}$') THEN 'Valid Email' ELSE 'Invalid Email' END AS IsValidEmail\r\nFROM   (VALUES ('John Doe', 'john@contoso.com'), ('Alice Smith', 'alice@fabrikam.com'), ('Bob Johnson', 'bob@fabrikam.net'), ('Charlie Brown', 'charlie@contoso.co.in'), ('Eve Jones', 'eve@@contoso.com')) AS e(Name, Email);<\/code><\/pre>\n<p>We can further use REGEXP_LIKE in <strong>CHECK constraints<\/strong> to enforce these rules at the column level (so no invalid format ever gets into the table). For instance:<\/p>\n<pre class=\"prettyprint language-sql\"><code class=\"language-sql\">CREATE TABLE Employees (\r\n    ...,\r\n    Email VARCHAR (320) CHECK (REGEXP_LIKE (Email, '^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}$')),\r\n    Phone VARCHAR (20)  CHECK (REGEXP_LIKE (Phone, '^(\\d{3})-(\\d{3})-(\\d{4})$'))\r\n);<\/code><\/pre>\n<p>This level of enforcement significantly enhances data integrity by ensuring that only correctly formatted values are accepted into the database.<\/p>\n<h3><code>REGEXP_COUNT<\/code>: Count JSON object keys<\/h3>\n<div class=\"paragraph-in-scc-markdown-text ___1ngh792 ftgm304 f1iaxwol\">Count how many <strong>top-level keys<\/strong> exist in a JSON string \u2014 no JSON parser needed!<\/div>\n<pre class=\"prettyprint language-sql\"><code class=\"language-sql\">SELECT JsonData,\r\n       REGEXP_COUNT(JsonData, '\"[^\"]+\"\\s*:', 1, 'i') AS NumKeys\r\nFROM   (VALUES ('{\"name\":\"Abhiman\",\"role\":\"PM\",\"location\":\"Bengaluru\"}'), ('{\"skills\":[\"SQL\",\"T-SQL\",\"Regex\"],\"level\":\"Advanced\"}'), ('{\"project\":{\"name\":\"Regex GA\",\"status\":\"Live\"},\"team\":[\"Tejas\",\"UC\"]}'), ('{\"empty\":{}}'), ('{}')) AS t(JsonData);\r\n<\/code><\/pre>\n<h3><code>REGEXP_INSTR<\/code>: Locate patterns in logs<\/h3>\n<p>Find the <strong>position<\/strong> of the first error code (<code>ERR-XXXX<\/code>) in log messages \u2014 even when the pattern appears multiple times or in varying locations.<\/p>\n<pre class=\"prettyprint language-sql\"><code class=\"language-sql\">SELECT LogMessage,\r\n       REGEXP_INSTR(LogMessage, 'ERR-\\d{4}', 1, 1, 0, 'i') AS ErrorCodePosition\r\nFROM   (VALUES ('System initialized. ERR-1001 occurred during startup.'), ('Warning: Disk space low. ERR-2048. Retry failed. ERR-2049.'), ('No errors found.'), ('ERR-0001: Critical failure. ERR-0002: Recovery started.'), ('Startup complete. Monitoring active.')) AS t(LogMessage);\r\n<\/code><\/pre>\n<h3><code>REGEXP_REPLACE<\/code>: Redact sensitive data<\/h3>\n<div class=\"paragraph-in-scc-markdown-text ___1ngh792 ftgm304 f1iaxwol\">Mask SSNs and credit card numbers in logs or exports \u2014 all with a single, secure query.<\/div>\n<div>\n<pre class=\"prettyprint language-sql\"><code class=\"language-sql\">SELECT sensitive_info,\r\n       REGEXP_REPLACE(sensitive_info, '(\\d{3}-\\d{2}-\\d{4}|\\d{4}-\\d{4}-\\d{4}-\\d{4})', '***-**-****') AS redacted_info\r\nFROM   (VALUES ('John Doe SSN: 123-45-6789'), ('Credit Card: 9876-5432-1098-7654'), ('SSN: 000-00-0000 and Card: 1111-2222-3333-4444'), ('No sensitive info here'), ('Multiple SSNs: 111-22-3333, 222-33-4444'), ('Card: 1234-5678-9012-3456, SSN: 999-88-7777')) AS t(sensitive_info);\r\n<\/code><\/pre>\n<h3><code>REGEXP_SUBSTR<\/code>: Extract and count email domains<\/h3>\n<div class=\"paragraph-in-scc-markdown-text ___1ngh792 ftgm304 f1iaxwol\">Extract domains from email addresses and group users by domain.<\/div>\n<pre class=\"prettyprint language-sql\"><code class=\"language-sql\">SELECT   REGEXP_SUBSTR(Email, '@(.+)$', 1, 1, 'i', 1) AS Domain,\r\n         COUNT(*) AS NumUsers\r\nFROM     (VALUES ('Alice', 'alice@contoso.com'), ('Bob', 'bob@fabrikam.co.in'), ('Charlie', 'charlie@example.com'), ('Diana', 'diana@college.edu'), ('Eve', 'eve@contoso.com'), ('Frank', 'frank@fabrikam.co.in'), ('Grace', 'grace@example.net')) AS e(Name, Email)\r\nWHERE    REGEXP_LIKE (Email, '^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$')\r\nGROUP BY REGEXP_SUBSTR(Email, '@(.+)$', 1, 1, 'i', 1);<\/code><\/pre>\n<h3><code>REGEXP_MATCHES<\/code>: Extract multiple emails from text<\/h3>\n<div>Extract all email addresses from free-form text like comments or logs \u2014 returning each match as a separate row for easy parsing or analysis.<\/div>\n<div>\n<pre class=\"prettyprint language-sql\"><code class=\"language-sql\">SELECT *\r\nFROM   REGEXP_MATCHES ('Contact us at support@example.com or sales@example.com', '[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}');<\/code><\/pre>\n<\/div>\n<div>\n<p>This query identifies and returns both email addresses found in the string \u2014 no need for loops, manual parsing, or external scripting.<\/p>\n<h3><code>REGEXP_SPLIT_TO_TABLE<\/code>: Break down structured text<\/h3>\n<div class=\"paragraph-in-scc-markdown-text ___1ngh792 ftgm304 f1iaxwol\">Split a string into rows using a Regex delimiter \u2014 ideal for parsing logs, config entries, or form data.<\/div>\n<div>\n<pre class=\"prettyprint language-sql\"><code class=\"language-sql\">SELECT *\r\nFROM   REGEXP_SPLIT_TO_TABLE ('Name: John Doe; Email: john.doe@example.com; Phone: 123-456-7890', '; ');<\/code><\/pre>\n<p>This query breaks the input string into rows for each field, making it easier to parse and process the data \u2014 especially when dealing with inconsistent or custom delimiters.<\/p>\n<p>To explore more examples, syntax options, and usage details, head over to the <a href=\"https:\/\/learn.microsoft.com\/en-us\/sql\/t-sql\/functions\/regular-expressions-functions-transact-sql?view=sql-server-ver17\">https:\/\/learn.microsoft.com\/en-us\/sql\/t-sql\/functions\/regular-expressions-functions-transact-sql?view=sql-server-ver17<\/a>.<\/p>\n<p><div class=\"alert alert-success\"><p class=\"alert-divider\"><i class=\"fabric-icon fabric-icon--Lightbulb\"><\/i><strong>Hint<\/strong><\/p>Writing complex Regex patterns can be tricky. Let Copilot help you generate and test patterns based on your requirements \u2014 right inside your SQL editor. Try asking Copilot for regex patterns!<\/div><\/p>\n<\/div>\n<\/div>\n<h2>Conclusion<\/h2>\n<p>The addition of Regex functionality in SQL Server 2025 and Azure SQL is a major leap forward for developers and DBAs. It eliminates the need for external libraries, CLR integration, or complex workarounds for text processing.<\/p>\n<p>With Regex now built into T-SQL, you can:<\/p>\n<ul>\n<li>Validate and enforce data formats<\/li>\n<li>Sanitize and transform sensitive data<\/li>\n<li>Search logs for complex patterns<\/li>\n<li>Extract and split structured content<\/li>\n<\/ul>\n<p>And this is just the beginning. Regex opens the door to a whole new level of <strong>data quality<\/strong>, <strong>text analytics<\/strong>, and <strong>developer productivity<\/strong> \u2014 all within the database engine. So go ahead and <strong>Regex away<\/strong>!<\/p>\n<\/div>\n<p>Your feedback and partnership continue to drive innovation in Azure SQL and SQL Server \u2014 thank you for being part of it.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We\u2019re excited to announce the General Availability (GA) of native Regex support in SQL Server 2025 and Azure SQL \u2014 a long-awaited capability that brings powerful pattern matching directly into T-SQL. This release marks a significant milestone in modernizing string operations and enabling advanced text processing scenarios natively within the database engine. What is Regex? [&hellip;]<\/p>\n","protected":false},"author":29335,"featured_media":81,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1,619],"tags":[607,606,608,700],"class_list":["post-6142","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-azure-sql","category-t-sql","tag-regex","tag-regular-expressions","tag-sql-regex-functions","tag-t-sql-regex"],"acf":[],"blog_post_summary":"<p>We\u2019re excited to announce the General Availability (GA) of native Regex support in SQL Server 2025 and Azure SQL \u2014 a long-awaited capability that brings powerful pattern matching directly into T-SQL. This release marks a significant milestone in modernizing string operations and enabling advanced text processing scenarios natively within the database engine. What is Regex? [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/posts\/6142","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/users\/29335"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/comments?post=6142"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/posts\/6142\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/media\/81"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/media?parent=6142"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/categories?post=6142"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/tags?post=6142"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}