Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 9522085

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 f003a75 commit 9522085

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

doc/src/sgml/func.sgml

+12-10
Original file line numberDiff line numberDiff line change
@@ -5329,7 +5329,7 @@ substring('foobar' similar '#"o_b#"%' escape '#') <lineannotation>NULL</linea
53295329
String matches regular expression, case sensitively
53305330
</para>
53315331
<para>
5332-
<literal>'thomas' ~ '.*thom.*'</literal>
5332+
<literal>'thomas' ~ 't.*ma'</literal>
53335333
<returnvalue>t</returnvalue>
53345334
</para></entry>
53355335
</row>
@@ -5343,7 +5343,7 @@ substring('foobar' similar '#"o_b#"%' escape '#') <lineannotation>NULL</linea
53435343
String matches regular expression, case insensitively
53445344
</para>
53455345
<para>
5346-
<literal>'thomas' ~* '.*Thom.*'</literal>
5346+
<literal>'thomas' ~* 'T.*ma'</literal>
53475347
<returnvalue>t</returnvalue>
53485348
</para></entry>
53495349
</row>
@@ -5357,8 +5357,8 @@ substring('foobar' similar '#"o_b#"%' escape '#') <lineannotation>NULL</linea
53575357
String does not match regular expression, case sensitively
53585358
</para>
53595359
<para>
5360-
<literal>'thomas' !~ '.*thomas.*'</literal>
5361-
<returnvalue>f</returnvalue>
5360+
<literal>'thomas' !~ 't.*max'</literal>
5361+
<returnvalue>t</returnvalue>
53625362
</para></entry>
53635363
</row>
53645364

@@ -5371,8 +5371,8 @@ substring('foobar' similar '#"o_b#"%' escape '#') <lineannotation>NULL</linea
53715371
String does not match regular expression, case insensitively
53725372
</para>
53735373
<para>
5374-
<literal>'thomas' !~* '.*vadim.*'</literal>
5375-
<returnvalue>t</returnvalue>
5374+
<literal>'thomas' !~* 'T.*ma'</literal>
5375+
<returnvalue>f</returnvalue>
53765376
</para></entry>
53775377
</row>
53785378
</tbody>
@@ -5406,10 +5406,12 @@ substring('foobar' similar '#"o_b#"%' escape '#') <lineannotation>NULL</linea
54065406
<para>
54075407
Some examples:
54085408
<programlisting>
5409-
'abc' ~ 'abc' <lineannotation>true</lineannotation>
5410-
'abc' ~ '^a' <lineannotation>true</lineannotation>
5411-
'abc' ~ '(b|d)' <lineannotation>true</lineannotation>
5412-
'abc' ~ '^(b|c)' <lineannotation>false</lineannotation>
5409+
'abcd' ~ 'bc' <lineannotation>true</lineannotation>
5410+
'abcd' ~ 'a.c' <lineannotation>true &mdash; dot matches any character</lineannotation>
5411+
'abcd' ~ 'a.*d' <lineannotation>true &mdash; <literal>*</literal> repeats the preceding pattern item</lineannotation>
5412+
'abcd' ~ '(b|x)' <lineannotation>true &mdash; <literal>|</literal> means OR, parentheses group</lineannotation>
5413+
'abcd' ~ '^a' <lineannotation>true &mdash; <literal>^</literal> anchors to start of string</lineannotation>
5414+
'abcd' ~ '^(b|c)' <lineannotation>false &mdash; would match except for anchoring</lineannotation>
54135415
</programlisting>
54145416
</para>
54155417

0 commit comments

Comments
 (0)