-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
252 lines (249 loc) · 82.3 KB
/
index.html
File metadata and controls
252 lines (249 loc) · 82.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
<!doctype html>
<html lang="en" dir="ltr" class="docs-wrapper plugin-docs plugin-id-default docs-version-current docs-doc-page docs-doc-id-sql/string" data-has-hydrated="false">
<head>
<meta charset="UTF-8">
<meta name="generator" content="Docusaurus v3.9.2">
<title data-rh="true">String Operations | Feldera Documentation</title><meta data-rh="true" name="viewport" content="width=device-width,initial-scale=1"><meta data-rh="true" name="twitter:card" content="summary_large_image"><meta data-rh="true" property="og:url" content="https://docs.feldera.com/sql/string"><meta data-rh="true" property="og:locale" content="en"><meta data-rh="true" name="docusaurus_locale" content="en"><meta data-rh="true" name="docsearch:language" content="en"><meta data-rh="true" name="docusaurus_version" content="current"><meta data-rh="true" name="docusaurus_tag" content="docs-default-current"><meta data-rh="true" name="docsearch:version" content="current"><meta data-rh="true" name="docsearch:docusaurus_tag" content="docs-default-current"><meta data-rh="true" property="og:title" content="String Operations | Feldera Documentation"><meta data-rh="true" name="description" content="The default character set for all strings is"><meta data-rh="true" property="og:description" content="The default character set for all strings is"><link data-rh="true" rel="icon" href="/img/favicon.ico"><link data-rh="true" rel="canonical" href="https://docs.feldera.com/sql/string"><link data-rh="true" rel="alternate" href="https://docs.feldera.com/sql/string" hreflang="en"><link data-rh="true" rel="alternate" href="https://docs.feldera.com/sql/string" hreflang="x-default"><link data-rh="true" rel="preconnect" href="https://WX24466N8W-dsn.algolia.net" crossorigin="anonymous"><script data-rh="true" type="application/ld+json">{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Pipelines","item":"https://docs.feldera.com/pipelines/"},{"@type":"ListItem","position":2,"name":"Feldera SQL","item":"https://docs.feldera.com/sql/"},{"@type":"ListItem","position":3,"name":"String Operations","item":"https://docs.feldera.com/sql/string"}]}</script><link rel="search" type="application/opensearchdescription+xml" title="Feldera Documentation" href="/opensearch.xml">
<link rel="preconnect" href="https://us.i.posthog.com">
<script>!function(t,e){var o,s,r,a;e.__SV||(window.posthog=e,e._i=[],e.init=function(i,n,p){function c(t,e){var o=e.split(".");2==o.length&&(t=t[o[0]],e=o[1]),t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}}(r=t.createElement("script")).type="text/javascript",r.async=!0,r.src=n.api_host.replace(".i.posthog.com","-assets.i.posthog.com")+"/static/array.js",(a=t.getElementsByTagName("script")[0]).parentNode.insertBefore(r,a);var g=e;for(void 0!==p?g=e[p]=[]:p="posthog",g.people=g.people||[],g.toString=function(t){var e="posthog";return"posthog"!==p&&(e+="."+p),t||(e+=" (stub)"),e},g.people.toString=function(){return g.toString(1)+".people (stub)"},o="capture identify alias people.set people.set_once set_config register register_once unregister opt_out_capturing has_opted_out_capturing opt_in_capturing reset isFeatureEnabled onFeatureFlags getFeatureFlag getFeatureFlagPayload reloadFeatureFlags group updateEarlyAccessFeatureEnrollment getEarlyAccessFeatures getActiveMatchingSurveys getSurveys onSessionId".split(" "),s=0;s<o.length;s++)c(g,o[s]);e._i.push([i,n,p])},e.__SV=1)}(document,window.posthog||[]),posthog.init("phc_GKR68l5zo531AD1R3cnE3MCPEBPXTqgYax4q053LVBD",{api_host:"https://us.i.posthog.com",id:"default"})</script>
<script async defer="defer" id="hs-script-loader" src="//js.hs-scripts.com/45801078.js"></script><link rel="stylesheet" href="/assets/css/styles.b3ba7e83.css">
<script src="/assets/js/runtime~main.d046107c.js" defer="defer"></script>
<script src="/assets/js/main.1a63e7da.js" defer="defer"></script>
</head>
<body class="navigation-with-keyboard">
<svg style="display: none;"><defs>
<symbol id="theme-svg-external-link" viewBox="0 0 24 24"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"/></symbol>
</defs></svg>
<script>document.documentElement.setAttribute("data-theme","light"),document.documentElement.setAttribute("data-theme-choice","light"),function(){try{const c=new URLSearchParams(window.location.search).entries();for(var[t,e]of c)if(t.startsWith("docusaurus-data-")){var a=t.replace("docusaurus-data-","data-");document.documentElement.setAttribute(a,e)}}catch(t){}}()</script><div id="__docusaurus"><div role="region" aria-label="Skip to main content"><a class="skipToContent_fXgn" href="#__docusaurus_skipToContent_fallback">Skip to main content</a></div><nav aria-label="Main" class="theme-layout-navbar navbar navbar--fixed-top"><div class="navbar__inner"><div class="theme-layout-navbar-left navbar__items"><button aria-label="Toggle navigation bar" aria-expanded="false" class="navbar__toggle clean-btn" type="button"><svg width="30" height="30" viewBox="0 0 30 30" aria-hidden="true"><path stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M4 7h22M4 15h22M4 23h22"></path></svg></button><a href="https://www.feldera.com" target="_blank" rel="noopener noreferrer" class="navbar__brand"><div class="navbar__logo"><img src="/img/logo-color-dark.svg" alt="Feldera Logo" class="themedComponent_mlkZ themedComponent--light_NVdE"><img src="/img/logo-color-light.svg" alt="Feldera Logo" class="themedComponent_mlkZ themedComponent--dark_xIcU"></div></a><a class="navbar__item navbar__link" href="/get-started">Get Started</a><a aria-current="page" class="navbar__item navbar__link navbar__link--active" href="/sql">SQL Reference</a><a class="navbar__item navbar__link" href="/connectors">Connectors</a></div><div class="theme-layout-navbar-right navbar__items navbar__items--right"><div class="navbar__item dropdown dropdown--hoverable dropdown--right"><a href="#" aria-haspopup="true" aria-expanded="false" role="button" class="navbar__link">Community</a><ul class="dropdown__menu"><li><a href="https://join.slack.com/t/felderacommunity/shared_invite/zt-222bq930h-dgsu5IEzAihHg8nQt~dHzA" target="_blank" rel="noopener noreferrer" class="dropdown__link">Slack<svg width="12" height="12" aria-label="(opens in new tab)" class="iconExternalLink_nPIU"><use href="#theme-svg-external-link"></use></svg></a></li><li><a href="https://discord.com/invite/s6t5n9UzHE" target="_blank" rel="noopener noreferrer" class="dropdown__link">Discord<svg width="12" height="12" aria-label="(opens in new tab)" class="iconExternalLink_nPIU"><use href="#theme-svg-external-link"></use></svg></a></li><li><a href="https://github.com/feldera/feldera" target="_blank" rel="noopener noreferrer" class="dropdown__link">GitHub<svg width="12" height="12" aria-label="(opens in new tab)" class="iconExternalLink_nPIU"><use href="#theme-svg-external-link"></use></svg></a></li></ul></div><div class="navbarSearchContainer_Bca1"><button type="button" class="DocSearch DocSearch-Button" aria-label="Search (Meta+k)" aria-keyshortcuts="Meta+k"><span class="DocSearch-Button-Container"><svg width="20" height="20" class="DocSearch-Search-Icon" viewBox="0 0 24 24" aria-hidden="true"><circle cx="11" cy="11" r="8" stroke="currentColor" fill="none" stroke-width="1.4"></circle><path d="m21 21-4.3-4.3" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"></path></svg><span class="DocSearch-Button-Placeholder">Search</span></span><span class="DocSearch-Button-Keys"></span></button></div></div></div><div role="presentation" class="navbar-sidebar__backdrop"></div></nav><div id="__docusaurus_skipToContent_fallback" class="theme-layout-main main-wrapper mainWrapper_z2l0"><div class="docsWrapper_hBAB"><button aria-label="Scroll back to top" class="clean-btn theme-back-to-top-button backToTopButton_sjWU" type="button"></button><div class="docRoot_UBD9"><aside class="theme-doc-sidebar-container docSidebarContainer_YfHR"><div class="sidebarViewport_aRkj"><div class="sidebar_njMd"><nav aria-label="Docs sidebar" class="menu thin-scrollbar menu_SIkG"><ul class="theme-doc-sidebar-menu menu__list"><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-1 menu__list-item"><a class="menu__link" href="/"><span title="What is Feldera?" class="linkLabel_WmDU">What is Feldera?</span></a></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="categoryLink_byQd menu__link menu__link--sublist menu__link--sublist-caret" role="button" aria-expanded="false" href="/architecture/enterprise"><span title="Architecture" class="categoryLinkLabel_W154">Architecture</span></a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="categoryLink_byQd menu__link menu__link--sublist" href="/get-started/"><span title="Install Feldera" class="categoryLinkLabel_W154">Install Feldera</span></a><button aria-label="Expand sidebar category 'Install Feldera'" aria-expanded="false" type="button" class="clean-btn menu__caret"></button></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="categoryLink_byQd menu__link menu__link--sublist" href="/tutorials/"><span title="Guides" class="categoryLinkLabel_W154">Guides</span></a><button aria-label="Expand sidebar category 'Guides'" aria-expanded="false" type="button" class="clean-btn menu__caret"></button></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item"><div class="menu__list-item-collapsible"><a class="categoryLink_byQd menu__link menu__link--sublist" href="/interface/"><span title="Feldera Interface" class="categoryLinkLabel_W154">Feldera Interface</span></a><button aria-label="Collapse sidebar category 'Feldera Interface'" aria-expanded="true" type="button" class="clean-btn menu__caret"></button></div><ul class="menu__list"><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/interface/web-console"><span title="Web Console" class="linkLabel_WmDU">Web Console</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/interface/cli"><span title="Command line tool (fda)" class="linkLabel_WmDU">Command line tool (fda)</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a href="/python/" target="_blank" rel="noopener noreferrer" class="menu__link menuExternalLink_NmtK" tabindex="0"><span title="Python SDK" class="linkLabel_WmDU">Python SDK</span><svg width="13.5" height="13.5" aria-label="(opens in new tab)" class="iconExternalLink_nPIU"><use href="#theme-svg-external-link"></use></svg></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a href="/api" target="_blank" rel="noopener noreferrer" class="menu__link menuExternalLink_NmtK" tabindex="0"><span title="REST API" class="linkLabel_WmDU">REST API</span><svg width="13.5" height="13.5" aria-label="(opens in new tab)" class="iconExternalLink_nPIU"><use href="#theme-svg-external-link"></use></svg></a></li></ul></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item"><div class="menu__list-item-collapsible"><a class="categoryLink_byQd menu__link menu__link--sublist menu__link--active" href="/pipelines/"><span title="Pipelines" class="categoryLinkLabel_W154">Pipelines</span></a><button aria-label="Collapse sidebar category 'Pipelines'" aria-expanded="true" type="button" class="clean-btn menu__caret"></button></div><ul class="menu__list"><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-2 menu__list-item"><div class="menu__list-item-collapsible"><a class="categoryLink_byQd menu__link menu__link--sublist menu__link--active" tabindex="0" href="/sql/"><span title="Feldera SQL" class="categoryLinkLabel_W154">Feldera SQL</span></a><button aria-label="Collapse sidebar category 'Feldera SQL'" aria-expanded="true" type="button" class="clean-btn menu__caret"></button></div><ul class="menu__list"><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/sql/grammar"><span title="SQL Grammar" class="linkLabel_WmDU">SQL Grammar</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/sql/identifiers"><span title="Identifiers" class="linkLabel_WmDU">Identifiers</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/sql/types"><span title="Data Types" class="linkLabel_WmDU">Data Types</span></a></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-3 menu__list-item"><div class="menu__list-item-collapsible"><a class="categoryLink_byQd menu__link menu__link--sublist menu__link--sublist-caret menu__link--active" role="button" aria-expanded="true" tabindex="0" href="/sql/aggregates"><span title="Operations" class="categoryLinkLabel_W154">Operations</span></a></div><ul class="menu__list"><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-4 menu__list-item"><a class="menu__link" tabindex="0" href="/sql/aggregates"><span title="Aggregate Operations" class="linkLabel_WmDU">Aggregate Operations</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-4 menu__list-item"><a class="menu__link" tabindex="0" href="/sql/array"><span title="Array Operations" class="linkLabel_WmDU">Array Operations</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-4 menu__list-item"><a class="menu__link" tabindex="0" href="/sql/binary"><span title="Binary (Byte Array) Operations" class="linkLabel_WmDU">Binary (Byte Array) Operations</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-4 menu__list-item"><a class="menu__link" tabindex="0" href="/sql/boolean"><span title="Boolean Operations" class="linkLabel_WmDU">Boolean Operations</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-4 menu__list-item"><a class="menu__link" tabindex="0" href="/sql/casts"><span title="Casts and Data Type Conversions" class="linkLabel_WmDU">Casts and Data Type Conversions</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-4 menu__list-item"><a class="menu__link" tabindex="0" href="/sql/comparisons"><span title="Comparison Operations" class="linkLabel_WmDU">Comparison Operations</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-4 menu__list-item"><a class="menu__link" tabindex="0" href="/sql/datetime"><span title="Date- and Time-Related Operations" class="linkLabel_WmDU">Date- and Time-Related Operations</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-4 menu__list-item"><a class="menu__link" tabindex="0" href="/sql/decimal"><span title="Decimal Operations" class="linkLabel_WmDU">Decimal Operations</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-4 menu__list-item"><a class="menu__link" tabindex="0" href="/sql/float"><span title="Floating Point Operations" class="linkLabel_WmDU">Floating Point Operations</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-4 menu__list-item"><a class="menu__link" tabindex="0" href="/sql/function-index"><span title="Index of Functions and SQL Constructs Supported in Feldera SQL" class="linkLabel_WmDU">Index of Functions and SQL Constructs Supported in Feldera SQL</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-4 menu__list-item"><a class="menu__link" tabindex="0" href="/sql/integer"><span title="Integer Operations" class="linkLabel_WmDU">Integer Operations</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-4 menu__list-item"><a class="menu__link" tabindex="0" href="/sql/json"><span title="JSON and Dynamically-Typed Value Support" class="linkLabel_WmDU">JSON and Dynamically-Typed Value Support</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-4 menu__list-item"><a class="menu__link" tabindex="0" href="/sql/map"><span title="Map Operations" class="linkLabel_WmDU">Map Operations</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-4 menu__list-item"><a class="menu__link" tabindex="0" href="/sql/operators"><span title="Operators" class="linkLabel_WmDU">Operators</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-4 menu__list-item"><a class="menu__link menu__link--active" aria-current="page" tabindex="0" href="/sql/string"><span title="String Operations" class="linkLabel_WmDU">String Operations</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-4 menu__list-item"><a class="menu__link" tabindex="0" href="/sql/table"><span title="Table Functions" class="linkLabel_WmDU">Table Functions</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-4 menu__list-item"><a class="menu__link" tabindex="0" href="/sql/uuid"><span title="UUID Operations" class="linkLabel_WmDU">UUID Operations</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-4 menu__list-item"><a class="menu__link" tabindex="0" href="/sql/unsupported-operations"><span title="Unsupported and Limited SQL Operations" class="linkLabel_WmDU">Unsupported and Limited SQL Operations</span></a></li></ul></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/sql/materialized"><span title="Materialized Tables and Views" class="linkLabel_WmDU">Materialized Tables and Views</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/sql/recursion"><span title="Mutually-Recursive Queries" class="linkLabel_WmDU">Mutually-Recursive Queries</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/sql/ad-hoc"><span title="Ad-hoc SQL Queries" class="linkLabel_WmDU">Ad-hoc SQL Queries</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/sql/streaming"><span title="Time-Series Extensions" class="linkLabel_WmDU">Time-Series Extensions</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/sql/system"><span title="System Views" class="linkLabel_WmDU">System Views</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/sql/udf"><span title="User-Defined Functions" class="linkLabel_WmDU">User-Defined Functions</span></a></li></ul></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-2 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="categoryLink_byQd menu__link menu__link--sublist" tabindex="0" href="/connectors/"><span title="Connectors" class="categoryLinkLabel_W154">Connectors</span></a><button aria-label="Expand sidebar category 'Connectors'" aria-expanded="false" type="button" class="clean-btn menu__caret"></button></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-2 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="categoryLink_byQd menu__link menu__link--sublist" tabindex="0" href="/formats/"><span title="Formats" class="categoryLinkLabel_W154">Formats</span></a><button aria-label="Expand sidebar category 'Formats'" aria-expanded="false" type="button" class="clean-btn menu__caret"></button></div></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/pipelines/lifecycle"><span title="Reference: Pipeline Lifecycle" class="linkLabel_WmDU">Reference: Pipeline Lifecycle</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/pipelines/configuration"><span title="Settings" class="linkLabel_WmDU">Settings</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/pipelines/fault-tolerance"><span title="Fault tolerance and checkpoint/resume" class="linkLabel_WmDU">Fault tolerance and checkpoint/resume</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/pipelines/modifying"><span title="Modifying a Pipeline" class="linkLabel_WmDU">Modifying a Pipeline</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/pipelines/checkpoint-sync"><span title="Synchronizing checkpoints to object store" class="linkLabel_WmDU">Synchronizing checkpoints to object store</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/pipelines/transactions"><span title="Efficient Bulk Data Processing using Transactions" class="linkLabel_WmDU">Efficient Bulk Data Processing using Transactions</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/pipelines/latency"><span title="Measuring Pipeline Latency" class="linkLabel_WmDU">Measuring Pipeline Latency</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/pipelines/sidecar"><span title="Sidecar Containers" class="linkLabel_WmDU">Sidecar Containers</span></a></li></ul></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="categoryLink_byQd menu__link menu__link--sublist menu__link--sublist-caret" role="button" aria-expanded="false" href="/operations/guide"><span title="Feldera Operations" class="categoryLinkLabel_W154">Feldera Operations</span></a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="categoryLink_byQd menu__link menu__link--sublist menu__link--sublist-caret" role="button" aria-expanded="false" href="/literature/papers"><span title="Literature" class="categoryLinkLabel_W154">Literature</span></a></div></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-1 menu__list-item"><a class="menu__link" href="/changelog"><span title="Changelog" class="linkLabel_WmDU">Changelog</span></a></li></ul></nav></div></div></aside><main class="docMainContainer_TBSr"><div class="container padding-top--md padding-bottom--lg"><div class="row"><div class="col docItemCol_VOVn"><div class="docItemContainer_Djhp"><article><nav class="theme-doc-breadcrumbs breadcrumbsContainer_Z_bl" aria-label="Breadcrumbs"><ul class="breadcrumbs"><li class="breadcrumbs__item"><a aria-label="Home page" class="breadcrumbs__link" href="/"><svg viewBox="0 0 24 24" class="breadcrumbHomeIcon_YNFT"><path d="M10 19v-5h4v5c0 .55.45 1 1 1h3c.55 0 1-.45 1-1v-7h1.7c.46 0 .68-.57.33-.87L12.67 3.6c-.38-.34-.96-.34-1.34 0l-8.36 7.53c-.34.3-.13.87.33.87H5v7c0 .55.45 1 1 1h3c.55 0 1-.45 1-1z" fill="currentColor"></path></svg></a></li><li class="breadcrumbs__item"><a class="breadcrumbs__link" href="/pipelines/"><span>Pipelines</span></a></li><li class="breadcrumbs__item"><a class="breadcrumbs__link" href="/sql/"><span>Feldera SQL</span></a></li><li class="breadcrumbs__item"><span class="breadcrumbs__link">Operations</span></li><li class="breadcrumbs__item breadcrumbs__item--active"><span class="breadcrumbs__link">String Operations</span></li></ul></nav><div class="tocCollapsible_ETCw theme-doc-toc-mobile tocMobile_ITEo"><button type="button" class="clean-btn tocCollapsibleButton_TO0P">On this page</button></div><div class="theme-doc-markdown markdown"><header><h1>String Operations</h1></header>
<p>The default character set for all strings is
<a href="https://en.wikipedia.org/wiki/UTF-8" target="_blank" rel="noopener noreferrer" class="">UTF-8</a>.</p>
<p>SQL defines two primary character types: <code>character varying(n)</code> and
<code>character(n)</code>, where n is a positive integer. Both of these types
can store strings up to n characters (not bytes) in length. An attempt
to store a longer string into a column of these types will result in
an error, unless the excess characters are all spaces, in which case
the string will be truncated to the maximum length. (This somewhat
bizarre exception is required by the SQL standard.) If the string to
be stored is shorter than the declared length, values of type
character will be space-padded; values of type character varying will
simply store the shorter string.</p>
<p>In addition, we provide the <code>text</code>, or <code>varchar</code> type, which stores
strings of any length.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="string-constants-literals">String constants (literals)<a href="#string-constants-literals" class="hash-link" aria-label="Direct link to String constants (literals)" title="Direct link to String constants (literals)" translate="no"></a></h2>
<p>A string constant in SQL is an arbitrary sequence of characters
bounded by single quotes (<code>'</code>), for example <code>'This is a string'</code>. To
include a single-quote character within a string constant, write two
adjacent single quotes, e.g., <code>'Dianne''s horse'</code>. Note that this is
not the same as a double-quote character (<code>"</code>).</p>
<p>Two string constants that are only separated by whitespace with at
least one newline are concatenated and effectively treated as if the
string had been written as one constant. For example:</p>
<div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token keyword" style="color:#00009f">SELECT</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'foo'</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token string" style="color:#e3116c">'bar'</span><br></span></code></pre></div></div>
<p>is equivalent to:</p>
<div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token keyword" style="color:#00009f">SELECT</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'foobar'</span><br></span></code></pre></div></div>
<p>but:</p>
<div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token keyword" style="color:#00009f">SELECT</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'foo'</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'bar'</span><br></span></code></pre></div></div>
<p>is not valid syntax. Newlines are supported within string literals:</p>
<div class="language-text codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-text codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token plain">SELECT 'a</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">b'</span><br></span></code></pre></div></div>
<p>produces a multi-line string literal.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="unicode-characters">Unicode characters<a href="#unicode-characters" class="hash-link" aria-label="Direct link to Unicode characters" title="Direct link to Unicode characters" translate="no"></a></h2>
<p>A string literal prefixed with the <code>U&</code> can contain Unicode characters
described using their numeric code: <code>U&'hello\0041'</code> includes the
Unicode character with code U+0041, which is the uppercase letter 'A'.
A Unicode character is described by an escape character followed by
four hexadecimal digits.</p>
<p>The default escape character is backslash, but it can be changed using
the following syntax: <code>U&'hello!0041' UESCAPE '!'</code>. The <code>UESCAPE</code>
notation designates the escape character to use in interpreting the
current literal, which is the exclamation sign in the previous
example.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="operations-on-string-values">Operations on string values<a href="#operations-on-string-values" class="hash-link" aria-label="Direct link to Operations on string values" title="Direct link to Operations on string values" translate="no"></a></h2>
<table><tr><th>Operation</th><th>Description</th><th>Examples</th></tr><tr><td><a id="concat"></a><code>||</code></td><td>String concatenation (infix). Note that concatenation does <em>not</em> strip trailing spaces
from CHAR(N) values, unlike other SQL dialects. If such behavior is desired, an explicit
cast to <code>varchar</code> can be added.</td><td><code>'Post' || 'greSQL'</code> => <code>PostgreSQL</code></td></tr><tr><td><a id="like"></a><code>string LIKE pattern [ESCAPE escape-character]</code> and
<code>string NOT LIKE pattern [ESCAPE escape-character]</code></td><td>The LIKE expression returns true if <code>string</code> matches <code>pattern</code>.
(As expected, the <code>NOT LIKE</code> expression returns false if <code>LIKE</code> returns true.)</td><td>See <a href="#like" class=""><code>LIKE</code></a> for details.</td></tr><tr><td><a id="ilike"></a><p><code>string ILIKE pattern </code> and
<code>string NOT ILIKE pattern</code></p></td><td><p>The <code>ILIKE</code> expression returns true if <code>string</code> matches <code>pattern</code>,
performing a case-insensitive comparison. This means that differences in character case
between the string and the pattern are ignored.
(Similarly, the <code>NOT ILIKE</code> expression returns false if <code>ILIKE</code> returns true.)</p></td><td><p>See <a href="#ilike" class=""><code>ILIKE</code></a> for details.</p></td></tr><tr><td><a id="rlike"></a><code>string RLIKE pattern</code> and
<code>string NOT RLIKE pattern</code></td><td>The RLIKE expression returns true if <code>string</code> matches <code>pattern</code>.
The pattern is a standard Rust regular expression.</td><td><code>'string' RLIKE 's..i.*'</code> => <code>TRUE</code></td></tr><tr><td><a id="ascii"></a><code>ASCII ( string )</code></td><td>Returns the numeric code of the first character of <code>string</code>. In UTF8 encoding, returns the Unicode code point of the character. In other multibyte encodings, the argument must be an ASCII character. Returns 0 if the string is empty.</td><td><code>ascii('x')</code> => <code>120</code></td></tr><tr><td><a id="char_length"></a><code>CHAR_LENGTH(string)</code> or <code>CHARACTER_LENGTH(string)</code> or <code>LENGTH(string)</code> or <code>LEN(string)</code></td><td>Returns number of characters in <code>string</code>.</td><td><code>char_length('josé')</code> => <code>4</code></td></tr><tr><td><a id="chr"></a><code>CHR ( integer )</code></td><td>Returns a string containing the character numbered <code>integer</code>. If the code is incorrect (e.g., negative), the result is an empty string.</td><td><code>chr(65)</code> => <code>A</code></td></tr><tr><td><a id="concat"></a><code>CONCAT(</code>string1, ..., stringN<code>)</code></td><td>String concatenation. Can have any number of arguments.</td><td><code>CONCAT('Post', 'greSQL', 1)</code> => <code>PostgreSQL1</code></td></tr><tr><td><a id="concat_ws"></a><code>CONCAT_WS(</code>sep, string1, ..., stringN<code>)</code></td><td>String concatenation with separator <code>sep</code>. Can have any number of arguments. <code>sep</code> is intercalated between all strings. If <code>sep</code> is <code>NULL</code> result is <code>NULL</code>. Other <code>NULL</code> arguments are ignored.</td><td><code>CONCAT_WS(',', 'Post', 'greSQL', NULL, '1')</code> => <code>Post,greSQL,1</code></td></tr><tr><td><a id="initcap"></a><code>INITCAP ( string )</code></td><td>Converts the first letter of each word in <code>string</code> to upper case and the rest to lower case. Words are sequences of alphanumeric characters separated by non-alphanumeric characters.</td><td><code>initcap('hi THOMAS')</code> => <code>Hi Thomas</code></td></tr><tr><td><a id="initcap_spaces"></a><code>INITCAP_SPACES ( string )</code></td><td>Converts the first letter of each word in <code>string</code> to upper case and the rest to lower case. Words are sequences of characters separated by spaces.</td><td><code>initcap('hi THOMAS-SON')</code> => <code>Hi Thomas-son</code></td></tr><tr><td><a id="left"></a><code>LEFT ( string, count )</code></td><td>Returns first <code>count</code> characters in <code>string</code>. If any argument is <code>NULL</code>, returns <code>NULL</code>.</td><td><code>left('abcde', 2)</code> => <code>ab</code></td></tr><tr><td><a id="lower"></a><code>LOWER ( string )</code></td><td>Converts <code>string</code> to all lower case.</td><td><code>lower('TOM')</code> => <code>tom</code></td></tr><tr><td><a id="md5"></a><code>MD5</code>(string)</td><td><p>Calculates an MD5 128-bit checksum of <code>string</code> and returns it as a hex <code>VARCHAR</code> value.
If the input is NULL, NULL is returned.</p></td><td><code>SELECT md5('Feldera')</code> => <code>841afc2f65b5763600818ef42a56d7d1</code></td></tr><tr><td><a id="overlay"></a><code>OVERLAY ( string PLACING newsubstring FROM start [ FOR remove ] )</code></td><td>Replaces the substring of <code>string</code> that starts at the <code>start</code>'th character and extends for <code>remove</code> characters with <code>newsubstring</code>. If <code>count</code> is omitted, it defaults to the length of <code>newsubstring</code>. If <code>start</code> is not positive, the original string is unchanged. If <code>start</code> is bigger than the length of <code>string</code>, the result is the concatenation of the two strings. If <code>remove</code> is negative it is considered 0.</td><td><code>overlay('Txxxxas' placing 'hom' from 2 for 4)</code> => <code>Thomas</code></td></tr><tr><td><a id="position"></a><code>POSITION(substring IN string)</code></td><td>Returns the first Unicode character index of <code>substring</code> within <code>string</code>, or zero if it's not present. First character has index 1.</td><td><code>position('om' in 'Thomas')</code> => <code>3</code></td></tr><tr><td><a id="regexp_replace"></a><code>REGEXP_REPLACE(expr, pat[, repl])</code></td><td>Replaces occurrences in the string <code>expr</code> that match the regular expression
specified by the pattern <code>pat</code> with the replacement string <code>repl</code>, and returns
the resulting string. If any one of <code>expr</code>, <code>pat</code>, or <code>repl</code> is <code>NULL</code>, the return value is <code>NULL</code>.
If <code>repl</code> is missing, it is assumed to be the empty string. If the regular
expression is invalid, the original string is returned.</td><td></td></tr><tr><td><a id="repeat"></a><code>REPEAT ( string, count )</code></td><td>Repeats <code>string</code> the specified number of times. The result is an empty string for a negative or 0 count.</td><td><code>repeat('Pg', 4)</code> => <code>PgPgPgPg</code></td></tr><tr><td><a id="replace"></a><code>REPLACE ( haystack, needle, replacement )</code></td><td>Replaces all occurrences of <code>needle</code> in <code>haystack</code> with <code>replacement</code>.</td><td><code>replace('abcdefabcdef', 'cd', 'XX')</code> => <code>abXXefabXXef</code></td></tr><tr><td><a id="right"></a><code>RIGHT ( string, count )</code></td><td>Returns last <code>count</code> characters in the string. If any argument is <code>NULL</code>, return <code>NULL</code>.</td><td><code>right('abcde', 2)</code> => <code>de</code></td></tr><tr><td><a id="rlike-function"></a><code>RLIKE(string, pattern)</code></td><td>A function equivalent to the <code>RLIKE</code> operator above.</td><td><code>RLIKE('string', 's..i.*')</code> => <code>TRUE</code></td></tr><tr><td><a id="split"></a><code>SPLIT(string [, delimiter])</code></td><td>Produce an array of strings, by splitting <code>string</code> at each occurrence of <code>delimiter</code>.
If <code>delimiter</code> is empty, return an array containing just <code>string</code>. If
<code>string</code> is empty, return an empty array. If either argument is NULL, return NULL.
If <code>delimiter</code> is absent assume it is the string <code>','</code>.</td><td><code>SPLIT('a|b|c|', '|')</code> => <code>['a', 'b', 'c', '']</code></td></tr><tr><td><a id="split_part"></a><code>SPLIT_PART(string, delimiter, n)</code></td><td><p>This function uses 1-based indexing. It extracts the <code>n</code>'th part of <code>string</code> by splitting it at each occurrence of <code>delimiter</code>.</p><ul><li><code>n = 1</code> refers to the first part of <code>string</code> after splitting.</li><li><code>n = 2</code> refers to the second part, and so on.</li><li>If <code>n</code> is negative, it returns the <code>abs(n)</code>'th part from the end of <code>string</code>.</li><li>If <code>n</code> is out of bounds, it returns an empty string.</li></ul></td><td><p><code>SPLIT_PART('a|b|c|', '|', 2)</code> => <code>b</code><br>
<code>SPLIT_PART('a|b|c|', '|', -2)</code> => <code>c</code><br>
<code>SPLIT_PART('a|b|c|', '|', 5)</code> => <code>''</code></p></td></tr><tr><td><a id="substr"></a><code>SUBSTR (</code> string, start, <code> [ ,</code> length <code>]</code></td><td>Extracts the substring of <code>string</code> starting at the <code>start</code>'th character, and stopping after <code>length</code> characters if the value is specified. If <code>start</code> is negative, the first character is chosen counting backwards from the end of <code>string</code>. If <code>count</code> is negative the empty string is returned. The index of the first character is 1.</td><td><code>SUBSTR('Thomas', 2, 3)</code> => <code>hom</code><br>
<code>SUBSTR('Thomas', 3)</code> => <code>omas</code><br></td></tr><tr><td><a id="substring"></a><code>SUBSTRING (</code> string <code>FROM</code> start <code> [ FOR</code> count<code> ] )</code></td><td>Extracts the substring of <code>string</code> starting at the <code>start</code>'th character, and stopping after <code>count</code> characters if the value is specified. If <code>start</code> is negative, only <code>max(count + start - 1, 0)</code> characters are returned. If <code>count</code> is negative the empty string is returned. The index of the first character is 1.</td><td><code>SUBSTRING('Thomas' from 2 for 3)</code> => <code>hom</code><br>
<code>SUBSTRING('Thomas' from 3)</code> => <code>omas</code><br></td></tr><tr><td><a id="trim"></a><code>TRIM ( [ LEADING | TRAILING | BOTH ]</code> characters <code>FROM</code> string <code>)</code></td><td>Remove <code>characters</code> from the specified ends of <code>string</code></td><td><code>TRIM(both 'xyz' from 'yxTomxx')</code> => <code>Tom</code><br><code>TRIM(leading 'xyz' from 'yxTomxx')</code> => <code>Tomxx</code></td></tr><tr><td><a id="upper"></a><code>UPPER ( string )</code></td><td>Converts <code>string</code> to all upper case.</td><td><code>upper('tom')</code> => <code>TOM</code></td></tr></table>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="like"><code>LIKE</code><a href="#like" class="hash-link" aria-label="Direct link to like" title="Direct link to like" translate="no"></a></h2>
<p>string <code>LIKE</code> pattern [<code>ESCAPE</code> escape-character]</p>
<p>string <code>NOT LIKE</code> pattern [<code>ESCAPE</code> escape-character]</p>
<p>If <code>pattern</code> does not contain percent signs or underscores, then the
pattern only represents the string itself; in that case <code>LIKE</code> acts
like the equals operator. An underscore (<code>_</code>) in <code>pattern</code> stands for
(matches) any single character; a percent sign (<code>%</code>) matches any
sequence of zero or more characters.</p>
<p>Some examples:</p>
<div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token string" style="color:#e3116c">'abc'</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">LIKE</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'abc'</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">true</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token string" style="color:#e3116c">'abc'</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">LIKE</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'a%'</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">true</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token string" style="color:#e3116c">'abc'</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">LIKE</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'_b_'</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">true</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token string" style="color:#e3116c">'abc'</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">LIKE</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'c'</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">false</span><br></span></code></pre></div></div>
<p><code>LIKE</code> pattern matching always covers the entire string. Therefore, if
it's desired to match a sequence anywhere within a string, the pattern
must start and end with a percent sign.</p>
<p>To match a literal underscore or percent sign without matching other
characters, the respective character in pattern must be preceded by
the escape character. The default escape character is the backslash
but a different one can be selected by using the <code>ESCAPE</code> clause. To
match the escape character itself, write two escape characters. The
escape character cannot be one of the special pattern characters <code>_</code>
or <code>%</code>.</p>
<p>Some examples where the escape character is changed to <code>#</code>:</p>
<div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token keyword" style="color:#00009f">SELECT</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'hawkeye'</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">LIKE</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'h%'</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">ESCAPE</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'#'</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">true</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token keyword" style="color:#00009f">SELECT</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'hawkeye'</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">NOT</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">LIKE</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'h%'</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">ESCAPE</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'#'</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">false</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token keyword" style="color:#00009f">SELECT</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'h%'</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">LIKE</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'h#%'</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">ESCAPE</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'#'</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">true</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token keyword" style="color:#00009f">SELECT</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'h%'</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">NOT</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">LIKE</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'h#%'</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">ESCAPE</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'#'</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">false</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token keyword" style="color:#00009f">SELECT</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'h%wkeye'</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">LIKE</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'h#%'</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">ESCAPE</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'#'</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">false</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token keyword" style="color:#00009f">SELECT</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'h%wkeye'</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">NOT</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">LIKE</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'h#%'</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">ESCAPE</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'#'</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">true</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token keyword" style="color:#00009f">SELECT</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'h%wkeye'</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">LIKE</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'h#%%'</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">ESCAPE</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'#'</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">true</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token keyword" style="color:#00009f">SELECT</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'h%wkeye'</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">NOT</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">LIKE</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'h#%%'</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">ESCAPE</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'#'</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">false</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token keyword" style="color:#00009f">SELECT</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'h%awkeye'</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">LIKE</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'h#%a%k%e'</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">ESCAPE</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'#'</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">true</span><br></span></code></pre></div></div>
<p>When either argument or <code>LIKE</code>, <code>NOT LIKE</code> is <code>NULL</code>, the result is <code>NULL</code>.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="ilike"><code>ILIKE</code><a href="#ilike" class="hash-link" aria-label="Direct link to ilike" title="Direct link to ilike" translate="no"></a></h2>
<p>string <code>ILIKE</code> pattern</p>
<p>string <code>NOT ILIKE</code> pattern</p>
<p>The <code>ILIKE</code> expression performs a case-insensitive pattern match. If
<code>pattern</code> does not contain percent signs or underscores,
then the pattern represents the string itself, and <code>ILIKE</code> acts like
the equals operator, ignoring character case. An underscore (<code>_</code>) in
<code>pattern</code> matches any single character, while a percent
sign (<code>%</code>) matches any sequence of zero or more characters.</p>
<p>Some examples:</p>
<div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token keyword" style="color:#00009f">SELECT</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'hawkeye'</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">ILIKE</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'h%'</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">true</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token keyword" style="color:#00009f">SELECT</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'hawkeye'</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">NOT</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">ILIKE</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'h%'</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">false</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token keyword" style="color:#00009f">SELECT</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'hawkeye'</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">ILIKE</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'H%'</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">true</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token keyword" style="color:#00009f">SELECT</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'hawkeye'</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">NOT</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">ILIKE</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'H%'</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">false</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token keyword" style="color:#00009f">SELECT</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'hawkeye'</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">ILIKE</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'H%Eye'</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">true</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token keyword" style="color:#00009f">SELECT</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'hawkeye'</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">NOT</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">ILIKE</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'H%Eye'</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">false</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token keyword" style="color:#00009f">SELECT</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'Hawkeye'</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">ILIKE</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'h%'</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">true</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token keyword" style="color:#00009f">SELECT</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'Hawkeye'</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">NOT</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">ILIKE</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'h%'</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">false</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token keyword" style="color:#00009f">SELECT</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'ABC'</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">ILIKE</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'_b_'</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">true</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token keyword" style="color:#00009f">SELECT</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'ABC'</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">NOT</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">ILIKE</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'_b_'</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">false</span><br></span></code></pre></div></div>
<p>When either argument or <code>ILIKE</code>, <code>NOT ILIKE</code> is <code>NULL</code>, the result is <code>NULL</code>.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="regular-expressions">Regular expressions<a href="#regular-expressions" class="hash-link" aria-label="Direct link to Regular expressions" title="Direct link to Regular expressions" translate="no"></a></h2>
<p>Regular expressions are matched using the <code>RLIKE</code> function. If either
argument of <code>RLIKE</code> is <code>NULL</code>, the result is also <code>NULL</code>. The
implementation is based on the Rust
<a href="https://docs.rs/regex/latest/regex/" target="_blank" rel="noopener noreferrer" class=""><code>Regex</code></a> library. The full
syntax supported is described in the <a href="https://docs.rs/regex/latest/regex/#syntax" target="_blank" rel="noopener noreferrer" class="">Rust
documentation</a>.</p>
<p>The description below uses fragments from the <a href="https://www.postgresql.org/docs/15/functions-matching.html#FUNCTIONS-POSIX-REGEXP" target="_blank" rel="noopener noreferrer" class="">Postgres
documentation</a>,
where credit is given to Henry Spencer.</p>
<p>Currently, our compiler does <em>not</em> support <code>SIMILAR TO</code> regular
expressions.</p>
<p>A regular expression is a character sequence that is an abbreviated
definition of a set of strings (a regular set). A string is said to
match a regular expression if it is a member of the regular set
described by the regular expression. As with <code>LIKE</code>, pattern
characters match string characters exactly unless they are special
characters in the regular expression language — but regular
expressions use different special characters than <code>LIKE</code> does. Unlike
<code>LIKE</code> patterns, a regular expression is allowed to match anywhere
within a string, unless the regular expression is explicitly anchored
to the beginning or end of the string.</p>
<p>A <em>regular expression</em> is defined as one or more <em>branches</em>, separated
by <code>|</code>. It matches anything that matches one of the branches.</p>
<p>A <em>branch</em> is zero or more <em>quantified atoms</em> or <em>constraints</em>,
concatenated. It matches a match for the first, followed by a match
for the second, etc.; an empty branch matches the empty string.</p>
<p>A <em>quantified atom</em> is an <em>atom</em> possibly followed by a single
<em>quantifier</em>. Without a quantifier, it matches a match for the
atom. With a quantifier, it can match some number of matches of the
atom. An atom can be any of the possibilities shown in the Table
below.</p>
<table><tr><th>Atom</th><th>Description</th></tr><tr><td><code>(re)</code></td><td>where <code>re</code> is any regular expression: matches a match for <code>re</code>, with the match noted for possible reporting</td></tr><tr><td><code>(?<!-- -->:re<!-- -->)</code></td><td>as above, but the match is not noted for reporting (a “non-capturing” set of parentheses)</td></tr><tr><td><code>.</code></td><td>matches any single character</td></tr><tr><td><code>[chars]</code></td><td>a bracket expression, matching any one of the chars (see below for more details)</td></tr><tr><td><code>\k</code></td><td>where <code>k</code> is a non-alphanumeric character): matches that character taken as an ordinary character, e.g.,
<code>\</code> matches a backslash character</td></tr><tr><td><code>\c</code></td><td>where <code>c</code> is alphanumeric (possibly followed by other characters): is an escape, see below</td></tr><tr><td><code>{</code></td><td>when followed by a character other than a digit, matches the left-brace character <code>{</code>;
when followed by a digit, it is the beginning of a bound (see below)</td></tr><tr><td>x</td><td>where <code>x</code> is a single character with no other significance, matches that character</td></tr></table>
<p>The possible quantifiers and their meanings are shown the Table below.</p>
<table><thead><tr><th>Quantifier</th><th>Matches</th></tr></thead><tbody><tr><td><code>*</code></td><td>a sequence of 0 or more matches of the atom</td></tr><tr><td><code>+</code></td><td>a sequence of 1 or more matches of the atom</td></tr><tr><td><code>?</code></td><td>a sequence of 0 or 1 matches of the atom</td></tr><tr><td><code>{</code>m<code>}</code></td><td>a sequence of exactly m matches of the atom</td></tr><tr><td><code>{</code>m<code>,}</code></td><td>a sequence of m or more matches of the atom</td></tr><tr><td><code>{</code>m<code>,</code>n<code>}</code></td><td>a sequence of m through n (inclusive) matches of the atom; m cannot exceed n</td></tr><tr><td><code>*?</code></td><td>non-greedy version of *</td></tr><tr><td><code>+?</code></td><td>non-greedy version of +</td></tr><tr><td><code>??</code></td><td>non-greedy version of ?</td></tr><tr><td><code>{</code>m<code>}?</code></td><td>non-greedy version of <code>{m}</code></td></tr><tr><td><code>{</code>m<code>,}?</code></td><td>non-greedy version of <code>{m,}</code></td></tr><tr><td><code>{</code>m<code>,</code>n<code>}?</code></td><td>non-greedy version of <code>{m,n}</code></td></tr></tbody></table>
<p>A constraint matches an empty string, but matches only when specific
conditions are met. A constraint can be used where an atom could be
used, except it cannot be followed by a quantifier. The simple
constraints are shown in the Table below; some more constraints are
described later.</p>
<table><thead><tr><th>Constraint</th><th>Description</th></tr></thead><tbody><tr><td><code>^</code></td><td>matches at the beginning of the string</td></tr><tr><td><code>$</code></td><td>matches at the end of the string</td></tr></tbody></table>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="bracket-expressions">Bracket Expressions<a href="#bracket-expressions" class="hash-link" aria-label="Direct link to Bracket Expressions" title="Direct link to Bracket Expressions" translate="no"></a></h3>
<p>A bracket expression is a list of characters enclosed in <code>[]</code>. It
normally matches any single character from the list (but see
below). If the list begins with <code>^</code>, it matches any single character
not from the rest of the list. If two characters in the list are
separated by <code>-</code>, this is shorthand for the full range of characters
between those two (inclusive) in the collating sequence, e.g., <code>[0-9]</code>
in ASCII matches any decimal digit. It is illegal for two ranges to
share an endpoint, e.g., <code>a-c-e</code>. Ranges are very
collating-sequence-dependent, so portable programs should avoid
relying on them.</p>
<p>To include a literal <code>]</code> in the list, make it the first character
(after <code>^</code>, if that is used). To include a literal <code>-</code>, make it the
first or last character, or the second endpoint of a range. To use a
literal <code>-</code> as the first endpoint of a range, enclose it in <code>[.</code> and
<code>.]</code>. With the exception of these characters, some combinations using
<code>[</code>, all other special characters lose their special significance
within a bracket expression. In particular, <code>\</code> is not special.</p>
<p>Within a bracket expression, the name of a character class enclosed in
<code>[:</code> and <code>:]</code> stands for the list of all characters belonging to that
class. A character class cannot be used as an endpoint of a range. The
POSIX standard defines these character class names:</p>
<table><thead><tr><th>Class</th><th>Description</th></tr></thead><tbody><tr><td><code>alnum</code></td><td>letters and numeric digits</td></tr><tr><td><code>alpha</code></td><td>letters</td></tr><tr><td><code>blank</code></td><td>space and tab</td></tr><tr><td><code>cntrl</code></td><td>control characters</td></tr><tr><td><code>digit</code></td><td>numeric digits</td></tr><tr><td><code>graph</code></td><td>printable characters except space</td></tr><tr><td><code>lower</code></td><td>lower-case letters</td></tr><tr><td><code>print</code></td><td>printable characters including space</td></tr><tr><td><code>punct</code></td><td>punctuation</td></tr><tr><td><code>space</code></td><td>any white space</td></tr><tr><td><code>upper</code></td><td>upper-case letters</td></tr><tr><td><code>xdigit</code></td><td>hexadecimal digits</td></tr></tbody></table>
<p>Class-shorthand escapes provide shorthands for certain commonly-used
character classes. They are shown in the table below.</p>
<table><thead><tr><th>Escape</th><th>Description</th></tr></thead><tbody><tr><td><code>\d</code></td><td>matches any digit, like [[:digit:]]</td></tr><tr><td><code>\s</code></td><td>matches any whitespace character, like [[:space:]]</td></tr><tr><td><code>\w</code></td><td>matches any word character, like [[:word:]]</td></tr><tr><td><code>\D</code></td><td>matches any non-digit, like [^[:digit:]]</td></tr><tr><td><code>\S</code></td><td>matches any non-whitespace character, like [^[:space:]]</td></tr><tr><td><code>\W</code></td><td>matches any non-word character, like [^[:word:]]</td></tr></tbody></table>
<p>The behavior of these standard character classes is generally
consistent across platforms for characters in the 7-bit ASCII set.
Whether a given non-ASCII character is considered to belong to one of
these classes depends on the collation that is used for the
regular-expression function or operator.</p>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="regular-expression-escapes">Regular Expression Escapes<a href="#regular-expression-escapes" class="hash-link" aria-label="Direct link to Regular Expression Escapes" title="Direct link to Regular Expression Escapes" translate="no"></a></h3>
<p>Escapes are special sequences beginning with <code>\</code> followed by an
alphanumeric character. Escapes come in several varieties: character
entry, class shorthands, and constraint escapes. A
<code>\</code> followed by an alphanumeric character but not constituting a valid
escape is illegal.</p>
<p>Character-entry escapes exist to make it easier to specify
non-printing and other inconvenient characters in REs. They are shown
in the Table below.</p>
<table><thead><tr><th>Escape</th><th>Description</th></tr></thead><tbody><tr><td><code>\n</code></td><td>newline, as in C</td></tr><tr><td><code>\r</code></td><td>carriage return, as in C</td></tr><tr><td><code>\t</code></td><td>horizontal tab, as in C</td></tr><tr><td><code>\u</code>wxyz</td><td>(where wxyz is exactly four hexadecimal digits) the character whose hexadecimal value is 0xwxyz</td></tr><tr><td><code>\x</code>hh</td><td>(where hh is a pair of hexadecimal digits) the character whose hexadecimal value is 0xhh</td></tr><tr><td><code>\0</code></td><td>the character whose value is 0 (the null byte)</td></tr></tbody></table>
<p>A constraint escape is a constraint, matching the empty string if
specific conditions are met, written as an escape. They are shown in
the Table below.</p>
<table><thead><tr><th>Escape</th><th>Description</th></tr></thead><tbody><tr><td><code>\A</code></td><td>matches only at the beginning of the string</td></tr><tr><td><code>\b</code></td><td>matches word boundaries</td></tr><tr><td><code>\B</code></td><td>not a word boundary</td></tr></tbody></table>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="capture-groups">Capture groups<a href="#capture-groups" class="hash-link" aria-label="Direct link to Capture groups" title="Direct link to Capture groups" translate="no"></a></h3>
<p>A common way to use regexes is with <em>capture groups</em>. That is, instead
of just looking for matches of an entire regex, parentheses are used
to create groups that represent part of the match.</p>
<p>For example, consider a string with multiple lines, and each line has
three whitespace delimited fields where the second field is expected
to be a number and the third field a boolean. This can be expressed
with the following regular expression, where the capture groups have
been labeled <code>$0</code> to <code>$4</code>.</p>
<div class="language-text codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-text codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token plain">(?m)^\s*(\S+)\s+([0-9]+)\s+(true|false)\s*$</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">^^^^ ^^^^^ ^^^^^^^^ ^^^^^^^^^^^^</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> $1 $2 $3 $4</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> $0</span><br></span></code></pre></div></div>
<p>Capture group 0 always corresponds to an implicit unnamed group that
includes the entire match. If a match is found, this group is always
present.</p>
<p>Subsequent groups may be named and are numbered, starting at 1, by the
order in which the opening parenthesis appears in the pattern. For
example, in the pattern <code>(?<a>.(?<b>.))(?<c>.)</code>, <code>a</code>, <code>b</code> and <code>c</code>
correspond to capture groups <code>$1</code>, <code>$2</code> and <code>$3</code>, respectively.</p>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="regular-expression-functions">Regular expression functions<a href="#regular-expression-functions" class="hash-link" aria-label="Direct link to Regular expression functions" title="Direct link to Regular expression functions" translate="no"></a></h3>
<div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token plain">REGEXP_REPLACE</span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">expr</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> pat</span><span class="token punctuation" style="color:#393A34">[</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> repl</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">)</span><br></span></code></pre></div></div>
<p>If <code>repl</code> is missing, it is assumed to be the empty string.</p>
<p>Replaces occurrences in the string <code>expr</code> that match the regular
expression specified by the pattern <code>pat</code> with the replacement string
<code>repl</code>, and returns the resulting string. If any of <code>expr</code>, <code>pat</code>, or
<code>repl</code> is <code>NULL</code>, the return value is <code>NULL</code>.</p>
<h4 class="anchor anchorTargetStickyNavbar_Vzrq" id="replacement-string-syntax">Replacement string syntax<a href="#replacement-string-syntax" class="hash-link" aria-label="Direct link to Replacement string syntax" title="Direct link to Replacement string syntax" translate="no"></a></h4>
<p>All instances of <code>$N</code> in the replacement string are replaced with the
substring corresponding to the capture group identified by <code>N</code>.</p>
<p><code>N</code> may be an integer corresponding to the index of the capture group
(counted by order of opening parenthesis where 0 is the entire match)
or it can be a name (consisting of letters, digits or underscores)
corresponding to a named capture group.</p>
<p>If <code>N</code> isn’t a valid capture group (whether the name doesn’t exist or
isn’t a valid index), then it is replaced with the empty string.</p>
<p>The longest possible name is used. For example, <code>$1a</code> looks up the
capture group named <code>1a</code> and not the capture group at index <code>1</code>. To
exert more precise control over the name, use braces, e.g., <code>${1}a</code>.</p>
<p>To write a literal <code>$</code> use <code>$$</code>.</p>
<p>Examples:</p>
<div class="language-text codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-text codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token plain">select regexp_replace('1078910', '[^01]');</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">1010</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">select regexp_replace('deep fried', '(?<first>\w+)\s+(?<second>\w+)', '${first}_$second');</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">deep_fried</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">select regexp_replace('Springsteen, Bruce', '([^,\s]+),\s+(\S+)', '$2 $1');</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">Bruce Springsteen</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">select regexp_replace('Springsteen, Bruce', '(?<last>[^,\s]+),\s+(?<first>\S+)', '$first $last');</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">Bruce Springsteen</span><br></span></code></pre></div></div>
<p>Note that using <code>$2</code> instead of <code>$first</code> or <code>$1</code> instead of <code>$last</code>
would produce the same result.</p></div></article><nav class="docusaurus-mt-lg pagination-nav" aria-label="Docs pages"><a class="pagination-nav__link pagination-nav__link--prev" href="/sql/operators"><div class="pagination-nav__sublabel">Previous</div><div class="pagination-nav__label">Operators</div></a><a class="pagination-nav__link pagination-nav__link--next" href="/sql/table"><div class="pagination-nav__sublabel">Next</div><div class="pagination-nav__label">Table Functions</div></a></nav></div></div><div class="col col--3"><div class="tableOfContents_bqdL thin-scrollbar theme-doc-toc-desktop"><ul class="table-of-contents table-of-contents__left-border"><li><a href="#string-constants-literals" class="table-of-contents__link toc-highlight">String constants (literals)</a></li><li><a href="#unicode-characters" class="table-of-contents__link toc-highlight">Unicode characters</a></li><li><a href="#operations-on-string-values" class="table-of-contents__link toc-highlight">Operations on string values</a></li><li><a href="#like" class="table-of-contents__link toc-highlight"><code>LIKE</code></a></li><li><a href="#ilike" class="table-of-contents__link toc-highlight"><code>ILIKE</code></a></li><li><a href="#regular-expressions" class="table-of-contents__link toc-highlight">Regular expressions</a><ul><li><a href="#bracket-expressions" class="table-of-contents__link toc-highlight">Bracket Expressions</a></li><li><a href="#regular-expression-escapes" class="table-of-contents__link toc-highlight">Regular Expression Escapes</a></li><li><a href="#capture-groups" class="table-of-contents__link toc-highlight">Capture groups</a></li><li><a href="#regular-expression-functions" class="table-of-contents__link toc-highlight">Regular expression functions</a></li></ul></li></ul></div></div></div></div></main></div></div></div><footer class="theme-layout-footer footer footer--dark"><div class="container container-fluid"><div class="row footer__links"><div class="theme-layout-footer-column col footer__col"><div class="footer__title">Docs</div><ul class="footer__items clean-list"><li class="footer__item"><a class="footer__link-item" href="/get-started">Get Started</a></li><li class="footer__item"><a class="footer__link-item" href="/tutorials/basics/part1">Tutorial</a></li><li class="footer__item"><a class="footer__link-item" href="/sql/intro">SQL Reference</a></li></ul></div><div class="theme-layout-footer-column col footer__col"><div class="footer__title">Community</div><ul class="footer__items clean-list"><li class="footer__item"><a href="https://join.slack.com/t/felderacommunity/shared_invite/zt-222bq930h-dgsu5IEzAihHg8nQt~dHzA" target="_blank" rel="noopener noreferrer" class="footer__link-item">Slack<svg width="13.5" height="13.5" aria-label="(opens in new tab)" class="iconExternalLink_nPIU"><use href="#theme-svg-external-link"></use></svg></a></li><li class="footer__item"><a href="https://discord.com/invite/s6t5n9UzHE" target="_blank" rel="noopener noreferrer" class="footer__link-item">Discord<svg width="13.5" height="13.5" aria-label="(opens in new tab)" class="iconExternalLink_nPIU"><use href="#theme-svg-external-link"></use></svg></a></li><li class="footer__item"><a href="https://bsky.app/profile/feldera.bsky.social" target="_blank" rel="noopener noreferrer" class="footer__link-item">Bluesky<svg width="13.5" height="13.5" aria-label="(opens in new tab)" class="iconExternalLink_nPIU"><use href="#theme-svg-external-link"></use></svg></a></li></ul></div><div class="theme-layout-footer-column col footer__col"><div class="footer__title">More</div><ul class="footer__items clean-list"><li class="footer__item"><a href="https://github.com/feldera/feldera" target="_blank" rel="noopener noreferrer" class="footer__link-item">GitHub<svg width="13.5" height="13.5" aria-label="(opens in new tab)" class="iconExternalLink_nPIU"><use href="#theme-svg-external-link"></use></svg></a></li></ul></div></div><div class="footer__bottom text--center"><div class="footer__copyright">Copyright © 2026 Feldera Inc.</div></div></div></footer></div>
</body>
</html>