{"id":2019,"date":"2025-02-11T16:35:04","date_gmt":"2025-02-11T09:35:04","guid":{"rendered":"https:\/\/www.pgtutorial.com\/?page_id=2019"},"modified":"2025-02-11T20:39:58","modified_gmt":"2025-02-11T13:39:58","slug":"postgresql-regexp_matches","status":"publish","type":"page","link":"https:\/\/www.pgtutorial.com\/postgresql-string-functions\/postgresql-regexp_matches\/","title":{"rendered":"PostgreSQL REGEXP_MATCHES Function"},"content":{"rendered":"\r\n<p><strong>Summary<\/strong>: in this tutorial, you&#8217;ll learn how to use the PostgreSQL <code>REGEXP_MATCHES<\/code> function to extract all matches of a POSIX regular expression pattern from a string.<\/p>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading\" id='introduction-to-the-postgresql-regexp_matches-function'>Introduction to the PostgreSQL REGEXP_MATCHES function <a href=\"#introduction-to-the-postgresql-regexp_matches-function\" class=\"anchor\" id=\"introduction-to-the-postgresql-regexp_matches-function\" title=\"Anchor for Introduction to the PostgreSQL REGEXP_MATCHES function\">#<\/a><\/h2>\r\n\r\n\r\n\r\n<p>In PostgreSQL, the <code>REGEXP_MATCHES<\/code> function allows you to find matches based on a <a href=\"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-regular-expressions\/#introduction-to-posix-regular-expressions\" target=\"_blank\" rel=\"noreferrer noopener\">POSIX regular expression<\/a>.<\/p>\r\n\r\n\r\n\r\n<p>Here&#8217;s the syntax of the <code>REGEXP_MATCHES<\/code> function:<\/p>\r\n\r\n\r\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\">REGEXP_MATCHES(string, pattern &#91;, flags])<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\r\n\r\n\r\n<p>The function accepts three arguments:<\/p>\r\n\r\n\r\n\r\n<ul class=\"wp-block-list\">\r\n<li><code>string<\/code>: The input string to search.<\/li>\r\n\r\n\r\n\r\n<li><code>pattern<\/code>: The POSIX regular expression pattern to match.<\/li>\r\n\r\n\r\n\r\n<li><code>flags<\/code> (optional): A text string that contains zero or more single-letter flags that control the behavior of the regular expression. For example, the <code>'i'<\/code> flag is for case-insensitive matching.<\/li>\r\n<\/ul>\r\n\r\n\r\n\r\n<p>The <code>REGEXP_MATCHES<\/code> function returns a set of text arrays (<code>SET OF TEXT[]<\/code>) that contains matching substrings.<\/p>\r\n\r\n\r\n\r\n<p>If the <code>pattern<\/code> does not match the <code>string<\/code>, the function returns an empty set (or no rows).<\/p>\r\n\r\n\r\n\r\n<p>If the <code>pattern<\/code> matches the <code>string<\/code>, the function may return one or more rows based on the arguments:<\/p>\r\n\r\n\r\n\r\n<ul class=\"wp-block-list\">\r\n<li>If the <code>pattern<\/code> has no capturing groups, the function returns one row (<code>TEXT[]<\/code>) that has one element containing the matching substring.<\/li>\r\n\r\n\r\n\r\n<li>If the <code>pattern<\/code> has capturing groups, the function returns one row (<code>TEXT[]<\/code>) that contains multiple elements, each corresponding to a capturing group.<\/li>\r\n\r\n\r\n\r\n<li>If the <code>flags<\/code> does not include the <code>g<\/code> flag, the function returns only the first match of each capturing group (<code>TEXT[]<\/code>).<\/li>\r\n\r\n\r\n\r\n<li>If the <code>flags<\/code> includes the <code>g<\/code> flag, the function returns the set of text arrays (<code>SET OF TEXT[]<\/code>).<\/li>\r\n<\/ul>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading\" id='postgresql-regexp_matches-function-examples'>PostgreSQL REGEXP_MATCHES function examples <a href=\"#postgresql-regexp_matches-function-examples\" class=\"anchor\" id=\"postgresql-regexp_matches-function-examples\" title=\"Anchor for PostgreSQL REGEXP_MATCHES function examples\">#<\/a><\/h2>\r\n\r\n\r\n\r\n<p>Let&#8217;s take some examples of using the <code>REGEXP_MATCHES<\/code> function.<\/p>\r\n\r\n\r\n\r\n<h3 class=\"wp-block-heading\" id='returning-no-rows'>Returning no rows <a href=\"#returning-no-rows\" class=\"anchor\" id=\"returning-no-rows\" title=\"Anchor for Returning no rows\">#<\/a><\/h3>\r\n\r\n\r\n\r\n<p>The following query uses the <code>REGEXP_MATCHES<\/code> function to find a substring with one or more digits:<\/p>\r\n\r\n\r\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">SELECT<\/span>\r\n  REGEXP_MATCHES(<span class=\"hljs-string\">'PostgreSQL'<\/span>, <span class=\"hljs-string\">'\\d+'<\/span>) result;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\r\n\r\n\r\n<p><a href=\"https:\/\/www.pgtutorial.com\/playground\/?q=U0VMRUNUIFJFR0VYUF9NQVRDSEVTKCdQb3N0Z3JlU1FMJywgJ1xkKycpIHJlc3VsdDs%3D\" target=\"_blank\" rel=\"noreferrer noopener\">Try it<\/a><\/p>\r\n\r\n\r\n\r\n<p>In this example, the input string has no digits. Therefore, the <code>\\d+<\/code> regular expression has no match. Hence, the <code>REGEXP_MATCHES<\/code> function returns an empty set:<\/p>\r\n\r\n\r\n<pre class=\"wp-block-code\"><span><code class=\"hljs\"> result\r\n--------\r\n(0 rows)<\/code><\/span><\/pre>\r\n\r\n\r\n<h3 class=\"wp-block-heading\" id='returning-first-match'>Returning first match <a href=\"#returning-first-match\" class=\"anchor\" id=\"returning-first-match\" title=\"Anchor for Returning first match\">#<\/a><\/h3>\r\n\r\n\r\n\r\n<p>The following statement uses the <code>REGEXP_MATCHES<\/code> function to find the first substring that contains one or more digits:<\/p>\r\n\r\n\r\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">SELECT\r\n  REGEXP_MATCHES(<span class=\"hljs-string\">'PostgreSQL 17, 2024'<\/span>, <span class=\"hljs-string\">'\\d+'<\/span>) result;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\r\n\r\n\r\n<p><a href=\"https:\/\/www.pgtutorial.com\/playground\/?q=U0VMRUNUIFJFR0VYUF9NQVRDSEVTKCdQb3N0Z3JlU1FMIDE3LCAyMDI0JywgJ1xkKycpIHJlc3VsdDs%3D\" target=\"_blank\" rel=\"noreferrer noopener\">Try it<\/a><\/p>\r\n\r\n\r\n\r\n<p>Output:<\/p>\r\n\r\n\r\n<pre class=\"wp-block-code\"><span><code class=\"hljs\"> result\r\n--------\r\n {17}<\/code><\/span><\/pre>\r\n\r\n\r\n<p>In this example, the <code>REGEXP_MATCHES<\/code> function returns one row, which is an array of text (<code>TEXT[]<\/code>) that has one element (<code>{17}<\/code>).<\/p>\r\n\r\n\r\n\r\n<p class=\"note\">Notice that the <a href=\"https:\/\/www.pgtutorial.com\/playground\/\" target=\"_blank\" rel=\"noreferrer noopener\">Playground<\/a> does not include the <code>{}<\/code> which indicates that the result is an array.<\/p>\r\n\r\n\r\n\r\n<h3 class=\"wp-block-heading\" id='returning-all-matches-with-the-g-flag'>Returning all matches with the g flag <a href=\"#returning-all-matches-with-the-g-flag\" class=\"anchor\" id=\"returning-all-matches-with-the-g-flag\" title=\"Anchor for Returning all matches with the g flag\">#<\/a><\/h3>\r\n\r\n\r\n\r\n<p>The following statement uses the <code>REGEXP_MATCHES<\/code> function to find all substrings that consist of one or more digits:<\/p>\r\n\r\n\r\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">SELECT\r\n  REGEXP_MATCHES(<span class=\"hljs-string\">'PostgreSQL 17, 2024'<\/span>, <span class=\"hljs-string\">'\\d+'<\/span>, <span class=\"hljs-string\">'g'<\/span>) result;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\r\n\r\n\r\n<p><a href=\"https:\/\/www.pgtutorial.com\/playground\/?q=U0VMRUNUIFJFR0VYUF9NQVRDSEVTKCdQb3N0Z3JlU1FMIDE3LCAyMDI0JywgJ1xkKycsICdnJykgcmVzdWx0Ow%3D%3D\" target=\"_blank\" rel=\"noreferrer noopener\">Try it<\/a><\/p>\r\n\r\n\r\n\r\n<p>Output:<\/p>\r\n\r\n\r\n<pre class=\"wp-block-code\"><span><code class=\"hljs\"> result\r\n--------\r\n {17}\r\n {2024}<\/code><\/span><\/pre>\r\n\r\n\r\n<p>In this example, we use the <code>g<\/code> flag to instruct the <code>REGEXP_MATCHES<\/code> function to return a <code>SET OF TEXT[]<\/code> that contains all matches. Each row is an array (<code>TEXT[]<\/code>) with one element that contains the match.<\/p>\r\n\r\n\r\n\r\n<h3 class=\"wp-block-heading\" id='returning-all-matches-with-capturing-groups'>Returning all matches with capturing groups <a href=\"#returning-all-matches-with-capturing-groups\" class=\"anchor\" id=\"returning-all-matches-with-capturing-groups\" title=\"Anchor for Returning all matches with capturing groups\">#<\/a><\/h3>\r\n\r\n\r\n\r\n<p>The following statement uses the <code>REGEXP_MATCHES<\/code> function to return all matches as a set of array of texts (<code>SET OF TEXT[]<\/code>):<\/p>\r\n\r\n\r\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">SELECT\r\n  REGEXP_MATCHES(<span class=\"hljs-string\">'John Doe, Jane Smith'<\/span>, <span class=\"hljs-string\">'(\\w+) (\\w+)'<\/span>, <span class=\"hljs-string\">'g'<\/span>) result;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\r\n\r\n\r\n<p><a href=\"https:\/\/www.pgtutorial.com\/playground\/?q=U0VMRUNUIFJFR0VYUF9NQVRDSEVTKCdKb2huIERvZSwgSmFuZSBTbWl0aCcsICcoXHcrKSAoXHcrKScsICdnJykgcmVzdWx0Ow%3D%3D\" target=\"_blank\" rel=\"noreferrer noopener\">Try it<\/a><\/p>\r\n\r\n\r\n\r\n<p>Output:<\/p>\r\n\r\n\r\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">    result\r\n--------------\r\n {John,Doe}\r\n {Jane,Smith}<\/code><\/span><\/pre>\r\n\r\n\r\n<p>In this example:<\/p>\r\n\r\n\r\n\r\n<ul class=\"wp-block-list\">\r\n<li>The regular expression\u00a0<code>(\\w+) (\\w+)<\/code>\u00a0has two capturing groups that match the first and second words.<\/li>\r\n\r\n\r\n\r\n<li>Each row contains an array of text with two elements: the first and last names.<\/li>\r\n<\/ul>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading\" id='using-regexp_matches-function-with-table-data'>Using REGEXP_MATCHES function with Table Data <a href=\"#using-regexp_matches-function-with-table-data\" class=\"anchor\" id=\"using-regexp_matches-function-with-table-data\" title=\"Anchor for Using REGEXP_MATCHES function with Table Data\">#<\/a><\/h2>\r\n\r\n\r\n\r\n<p>We&#8217;ll use the <code>products<\/code> table from the <code>inventory<\/code> database:<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"159\" height=\"254\" class=\"wp-image-1051\" src=\"https:\/\/www.pgtutorial.com\/wp-content\/uploads\/2024\/12\/products.png\" alt=\"PostgreSQL REGEXP_MATCHES function - sample table\" \/><\/figure>\r\n\r\n\r\n\r\n<p>The following query uses the <code>REGEXP_MATCH<\/code> function to find products with names that end with a number:<\/p>\r\n\r\n\r\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">SELECT<\/span>\r\n  product_name,\r\n  REGEXP_MATCHES(product_name, <span class=\"hljs-string\">'\\d+$'<\/span>, <span class=\"hljs-string\">'g'<\/span>) number\r\n<span class=\"hljs-keyword\">FROM<\/span>\r\n  products;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\r\n\r\n\r\n<p><a href=\"https:\/\/www.pgtutorial.com\/playground\/?q=U0VMRUNUIHByb2R1Y3RfbmFtZSwgUkVHRVhQX01BVENIKHByb2R1Y3RfbmFtZSwgJ1xkKycpIG51bWJlciBGUk9NIHByb2R1Y3RzOw%3D%3D\" target=\"_blank\" rel=\"noreferrer noopener\">Try it<\/a><\/p>\r\n\r\n\r\n\r\n<p>Output:<\/p>\r\n\r\n\r\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\">        product_name        | number\r\n<span class=\"hljs-comment\">----------------------------+--------<\/span>\r\n Samsung Galaxy S24         | {<span class=\"hljs-number\">24<\/span>}\r\n Apple iPhone <span class=\"hljs-number\">15<\/span>            | {<span class=\"hljs-number\">15<\/span>}\r\n Huawei Mate <span class=\"hljs-number\">60<\/span>             | {<span class=\"hljs-number\">60<\/span>}\r\n Xiaomi Mi <span class=\"hljs-number\">14<\/span>               | {<span class=\"hljs-number\">14<\/span>}\r\n Samsung Galaxy Z Fold <span class=\"hljs-number\">5<\/span>    | {<span class=\"hljs-number\">5<\/span>}\r\n...<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\r\n\r\n\r\n<h2 class=\"wp-block-heading\" id='common-use-cases'>Common Use Cases <a href=\"#common-use-cases\" class=\"anchor\" id=\"common-use-cases\" title=\"Anchor for Common Use Cases\">#<\/a><\/h2>\r\n\r\n\r\n\r\n<p>The <code>REGEXP_MATCHES<\/code> function can be helpful in the following cases:<\/p>\r\n\r\n\r\n\r\n<ul class=\"wp-block-list\">\r\n<li><strong>Data Extraction<\/strong>: Extracting data based on patterns from text such as phone numbers, emails, and error codes.<\/li>\r\n\r\n\r\n\r\n<li><strong>Data Validation<\/strong>: Validate data based on a specific pattern.<\/li>\r\n<\/ul>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading\" id='performance-considerations'>Performance Considerations <a href=\"#performance-considerations\" class=\"anchor\" id=\"performance-considerations\" title=\"Anchor for Performance Considerations\">#<\/a><\/h2>\r\n\r\n\r\n\r\n<p>When using the\u00a0 <code>REGEXP_MATCHES<\/code> function, you should consider the following:<\/p>\r\n\r\n\r\n\r\n<ul class=\"wp-block-list\">\r\n<li><strong>Regular Expression Complexity<\/strong>: If you use complex regular expressions, the function will be slow, especially with a large data set. Ensure to optimize your regular expressions for performance.<\/li>\r\n\r\n\r\n\r\n<li><strong>Index Utilization<\/strong>: The queries with the <code>REGEXP_MATCHES<\/code> function generally cannot utilize indexes, which results in full table scans. If the performance is critical, you can consider using functional indexes.<\/li>\r\n<\/ul>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading\" id='summary'>Summary <a href=\"#summary\" class=\"anchor\" id=\"summary\" title=\"Anchor for Summary\">#<\/a><\/h2>\r\n\r\n\r\n\r\n<ul class=\"wp-block-list\">\r\n<li>The <code>REGEXP_MATCHES<\/code> function returns a <code>SET OF TEXT[]<\/code>,\u00a0 where each array corresponds to a match.<\/li>\r\n\r\n\r\n\r\n<li>The capturing groups <code>()<\/code> will determine the number of elements in each array.<\/li>\r\n\r\n\r\n\r\n<li>The\u00a0<code>g<\/code>\u00a0flag controls whether the function returns all matches or only the first match.<\/li>\r\n\r\n\r\n\r\n<li>The <code>REGEXP_MATCHES<\/code> function returns no rows if there are no matches.<\/li>\r\n<\/ul>\r\n<div class=\"helpful-block-content\" data-title=\"\">\n\t<header>\n\t\t<div class=\"wth-question\">Was this tutorial helpful ?<\/div>\n\t\t<div class=\"wth-thumbs\">\n\t\t\t<button\n\t\t\t\tdata-post=\"2019\"\n\t\t\t\tdata-post-url=\"https:\/\/www.pgtutorial.com\/postgresql-string-functions\/postgresql-regexp_matches\/\"\n\t\t\t\tdata-post-title=\"PostgreSQL REGEXP_MATCHES Function\"\n\t\t\t\tdata-response=\"1\"\n\t\t\t\tclass=\"wth-btn-rounded wth-yes-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t\tclass=\"feather feather-thumbs-up block w-full h-full\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> Yes <\/span>\n\t\t\t<\/button>\n\n\t\t\t<button\n\t\t\t\tdata-response=\"0\"\n\t\t\t\tdata-post=\"2019\"\n\t\t\t\tdata-post-url=\"https:\/\/www.pgtutorial.com\/postgresql-string-functions\/postgresql-regexp_matches\/\"\n\t\t\t\tdata-post-title=\"PostgreSQL REGEXP_MATCHES Function\"\n\t\t\t\tclass=\"wth-btn-rounded wth-no-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> No <\/span>\n\t\t\t<\/button>\n\t\t<\/div>\n\t<\/header>\n\n\t<div class=\"wth-form hidden\">\n\t\t<div class=\"wth-form-wrapper\">\n\t\t\t<div class=\"wth-title\"><\/div>\n\t\t\t\n\t\t\t<textarea class=\"wth-message\"><\/textarea>\n\n\t\t\t<button class=\"btn btn-primary wth-btn-submit\">Send<\/button>\n\t\t\t<button class=\"btn wth-btn-cancel\">Cancel<\/button>\n\t\t\n\t\t<\/div>\n\t<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>You&#8217;ll learn how to use the PostgreSQL REGEXP_MATCHES function to extract all matches of a POSIX regular expression pattern from a string.<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":1800,"menu_order":22,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-2019","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>PostgreSQL REGEXP_MATCHES Function<\/title>\n<meta name=\"description\" content=\"You&#039;ll learn how to use the PostgreSQL REGEXP_MATCHES function to extract all matches of a POSIX regular expression pattern from a string.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.pgtutorial.com\/postgresql-string-functions\/postgresql-regexp_matches\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PostgreSQL REGEXP_MATCHES Function\" \/>\n<meta property=\"og:description\" content=\"You&#039;ll learn how to use the PostgreSQL REGEXP_MATCHES function to extract all matches of a POSIX regular expression pattern from a string.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.pgtutorial.com\/postgresql-string-functions\/postgresql-regexp_matches\/\" \/>\n<meta property=\"og:site_name\" content=\"PostgreSQL Tutorial\" \/>\n<meta property=\"article:modified_time\" content=\"2025-02-11T13:39:58+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.pgtutorial.com\/wp-content\/uploads\/2024\/12\/products.png\" \/>\n\t<meta property=\"og:image:width\" content=\"159\" \/>\n\t<meta property=\"og:image:height\" content=\"254\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.pgtutorial.com\\\/postgresql-string-functions\\\/postgresql-regexp_matches\\\/\",\"url\":\"https:\\\/\\\/www.pgtutorial.com\\\/postgresql-string-functions\\\/postgresql-regexp_matches\\\/\",\"name\":\"PostgreSQL REGEXP_MATCHES Function\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.pgtutorial.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.pgtutorial.com\\\/postgresql-string-functions\\\/postgresql-regexp_matches\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.pgtutorial.com\\\/postgresql-string-functions\\\/postgresql-regexp_matches\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.pgtutorial.com\\\/wp-content\\\/uploads\\\/2024\\\/12\\\/products.png\",\"datePublished\":\"2025-02-11T09:35:04+00:00\",\"dateModified\":\"2025-02-11T13:39:58+00:00\",\"description\":\"You'll learn how to use the PostgreSQL REGEXP_MATCHES function to extract all matches of a POSIX regular expression pattern from a string.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.pgtutorial.com\\\/postgresql-string-functions\\\/postgresql-regexp_matches\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.pgtutorial.com\\\/postgresql-string-functions\\\/postgresql-regexp_matches\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.pgtutorial.com\\\/postgresql-string-functions\\\/postgresql-regexp_matches\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.pgtutorial.com\\\/wp-content\\\/uploads\\\/2024\\\/12\\\/products.png\",\"contentUrl\":\"https:\\\/\\\/www.pgtutorial.com\\\/wp-content\\\/uploads\\\/2024\\\/12\\\/products.png\",\"width\":159,\"height\":254,\"caption\":\"PostgreSQL Expression Index\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.pgtutorial.com\\\/postgresql-string-functions\\\/postgresql-regexp_matches\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.pgtutorial.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PostgreSQL String Functions\",\"item\":\"https:\\\/\\\/www.pgtutorial.com\\\/postgresql-string-functions\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"PostgreSQL REGEXP_MATCHES Function\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.pgtutorial.com\\\/#website\",\"url\":\"https:\\\/\\\/www.pgtutorial.com\\\/\",\"name\":\"PostgreSQL Tutorial\",\"description\":\"Learn PostgreSQL from Scratch\",\"alternateName\":\"PostgreSQL\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.pgtutorial.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"PostgreSQL REGEXP_MATCHES Function","description":"You'll learn how to use the PostgreSQL REGEXP_MATCHES function to extract all matches of a POSIX regular expression pattern from a string.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.pgtutorial.com\/postgresql-string-functions\/postgresql-regexp_matches\/","og_locale":"en_US","og_type":"article","og_title":"PostgreSQL REGEXP_MATCHES Function","og_description":"You'll learn how to use the PostgreSQL REGEXP_MATCHES function to extract all matches of a POSIX regular expression pattern from a string.","og_url":"https:\/\/www.pgtutorial.com\/postgresql-string-functions\/postgresql-regexp_matches\/","og_site_name":"PostgreSQL Tutorial","article_modified_time":"2025-02-11T13:39:58+00:00","og_image":[{"width":159,"height":254,"url":"https:\/\/www.pgtutorial.com\/wp-content\/uploads\/2024\/12\/products.png","type":"image\/png"}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.pgtutorial.com\/postgresql-string-functions\/postgresql-regexp_matches\/","url":"https:\/\/www.pgtutorial.com\/postgresql-string-functions\/postgresql-regexp_matches\/","name":"PostgreSQL REGEXP_MATCHES Function","isPartOf":{"@id":"https:\/\/www.pgtutorial.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.pgtutorial.com\/postgresql-string-functions\/postgresql-regexp_matches\/#primaryimage"},"image":{"@id":"https:\/\/www.pgtutorial.com\/postgresql-string-functions\/postgresql-regexp_matches\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pgtutorial.com\/wp-content\/uploads\/2024\/12\/products.png","datePublished":"2025-02-11T09:35:04+00:00","dateModified":"2025-02-11T13:39:58+00:00","description":"You'll learn how to use the PostgreSQL REGEXP_MATCHES function to extract all matches of a POSIX regular expression pattern from a string.","breadcrumb":{"@id":"https:\/\/www.pgtutorial.com\/postgresql-string-functions\/postgresql-regexp_matches\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.pgtutorial.com\/postgresql-string-functions\/postgresql-regexp_matches\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pgtutorial.com\/postgresql-string-functions\/postgresql-regexp_matches\/#primaryimage","url":"https:\/\/www.pgtutorial.com\/wp-content\/uploads\/2024\/12\/products.png","contentUrl":"https:\/\/www.pgtutorial.com\/wp-content\/uploads\/2024\/12\/products.png","width":159,"height":254,"caption":"PostgreSQL Expression Index"},{"@type":"BreadcrumbList","@id":"https:\/\/www.pgtutorial.com\/postgresql-string-functions\/postgresql-regexp_matches\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.pgtutorial.com\/"},{"@type":"ListItem","position":2,"name":"PostgreSQL String Functions","item":"https:\/\/www.pgtutorial.com\/postgresql-string-functions\/"},{"@type":"ListItem","position":3,"name":"PostgreSQL REGEXP_MATCHES Function"}]},{"@type":"WebSite","@id":"https:\/\/www.pgtutorial.com\/#website","url":"https:\/\/www.pgtutorial.com\/","name":"PostgreSQL Tutorial","description":"Learn PostgreSQL from Scratch","alternateName":"PostgreSQL","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.pgtutorial.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/pages\/2019","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/comments?post=2019"}],"version-history":[{"count":12,"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/pages\/2019\/revisions"}],"predecessor-version":[{"id":2043,"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/pages\/2019\/revisions\/2043"}],"up":[{"embeddable":true,"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/pages\/1800"}],"wp:attachment":[{"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/media?parent=2019"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}