Skip to content

Commit dae5af6

Browse files
committed
Doc: work a little harder on the initial examples for regex matching.
Writing unnecessary '.*' at start and end of a POSIX regex doesn't do much except confuse the reader about whether that might be necessary after all. Make the examples in table 9.16 a tad more realistic, and try to turn the next group of examples into something self-contained. Per gripe from rmzgrimes. Back-patch to v13 because it's easy. Discussion: https://postgr.es/m/161215841824.14653.8969016349304314299@wrigleys.postgresql.org
1 parent d798ea7 commit dae5af6

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

doc/src/sgml/func.sgml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5266,7 +5266,7 @@ substring('foobar' from '#"o_b#"%' for '#') <lineannotation>NULL</lineannotat
52665266
String matches regular expression, case sensitively
52675267
</para>
52685268
<para>
5269-
<literal>'thomas' ~ '.*thom.*'</literal>
5269+
<literal>'thomas' ~ 't.*ma'</literal>
52705270
<returnvalue>t</returnvalue>
52715271
</para></entry>
52725272
</row>
@@ -5280,7 +5280,7 @@ substring('foobar' from '#"o_b#"%' for '#') <lineannotation>NULL</lineannotat
52805280
String matches regular expression, case insensitively
52815281
</para>
52825282
<para>
5283-
<literal>'thomas' ~* '.*Thom.*'</literal>
5283+
<literal>'thomas' ~* 'T.*ma'</literal>
52845284
<returnvalue>t</returnvalue>
52855285
</para></entry>
52865286
</row>
@@ -5294,8 +5294,8 @@ substring('foobar' from '#"o_b#"%' for '#') <lineannotation>NULL</lineannotat
52945294
String does not match regular expression, case sensitively
52955295
</para>
52965296
<para>
5297-
<literal>'thomas' !~ '.*thomas.*'</literal>
5298-
<returnvalue>f</returnvalue>
5297+
<literal>'thomas' !~ 't.*max'</literal>
5298+
<returnvalue>t</returnvalue>
52995299
</para></entry>
53005300
</row>
53015301

@@ -5308,8 +5308,8 @@ substring('foobar' from '#"o_b#"%' for '#') <lineannotation>NULL</lineannotat
53085308
String does not match regular expression, case insensitively
53095309
</para>
53105310
<para>
5311-
<literal>'thomas' !~* '.*vadim.*'</literal>
5312-
<returnvalue>t</returnvalue>
5311+
<literal>'thomas' !~* 'T.*ma'</literal>
5312+
<returnvalue>f</returnvalue>
53135313
</para></entry>
53145314
</row>
53155315
</tbody>
@@ -5343,10 +5343,12 @@ substring('foobar' from '#"o_b#"%' for '#') <lineannotation>NULL</lineannotat
53435343
<para>
53445344
Some examples:
53455345
<programlisting>
5346-
'abc' ~ 'abc' <lineannotation>true</lineannotation>
5347-
'abc' ~ '^a' <lineannotation>true</lineannotation>
5348-
'abc' ~ '(b|d)' <lineannotation>true</lineannotation>
5349-
'abc' ~ '^(b|c)' <lineannotation>false</lineannotation>
5346+
'abcd' ~ 'bc' <lineannotation>true</lineannotation>
5347+
'abcd' ~ 'a.c' <lineannotation>true &mdash; dot matches any character</lineannotation>
5348+
'abcd' ~ 'a.*d' <lineannotation>true &mdash; <literal>*</literal> repeats the preceding pattern item</lineannotation>
5349+
'abcd' ~ '(b|x)' <lineannotation>true &mdash; <literal>|</literal> means OR, parentheses group</lineannotation>
5350+
'abcd' ~ '^a' <lineannotation>true &mdash; <literal>^</literal> anchors to start of string</lineannotation>
5351+
'abcd' ~ '^(b|c)' <lineannotation>false &mdash; would match except for anchoring</lineannotation>
53505352
</programlisting>
53515353
</para>
53525354

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy