Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6a0f486

Browse files
committed
A little wordsmithing in the pattern-matching section.
1 parentd316f22 commit6a0f486

File tree

1 file changed

+54
-37
lines changed

1 file changed

+54
-37
lines changed

‎doc/src/sgml/func.sgml

Lines changed: 54 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/func.sgml,v 1.42 2000/12/1618:33:13 tgl Exp $ -->
1+
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/func.sgml,v 1.43 2000/12/1619:33:23 tgl Exp $ -->
22

33
<chapter id="functions">
44
<title>Functions and Operators</title>
@@ -805,12 +805,12 @@
805805

806806
<para>
807807
If <replaceable>pattern</replaceable> does not contain percent
808-
signs or underscore then the pattern only represents the string
808+
signs or underscore, then the pattern only represents the string
809809
itself; in that case <function>LIKE</function> acts like the
810810
equals operator. An underscore (<literal>_</literal>) in
811811
<replaceable>pattern</replaceable> stands for (matches) any single
812-
character, a percent sign (<literal>%</literal>) matcheszero or
813-
more characters.
812+
character; a percent sign (<literal>%</literal>) matchesany string
813+
of zero ormore characters.
814814
</para>
815815

816816
<informalexample>
@@ -827,33 +827,39 @@
827827

828828
<para>
829829
<function>LIKE</function> pattern matches always cover the entire
830-
string.On order to match a pattern anywhere within a string, the
830+
string.To match a pattern anywhere within a string, the
831831
pattern must therefore start and end with a percent sign.
832832
</para>
833833

834834
<para>
835-
In order to match a literal underscore or percent sign, the
836-
respective character in <replaceable>pattern</replaceable> must be
837-
preceded by the active escape character. The default escape
835+
To match a literal underscore or percent sign without matching
836+
other characters, the respective character in
837+
<replaceable>pattern</replaceable> must be
838+
preceded by the escape character. The default escape
838839
character is the backslash but a different one may be selected by
839-
using the <literal>ESCAPE</literal> clause. When using the
840-
backslash as escape character in literal strings it must be
841-
doubled, because the backslash already has a special meaning in
842-
string literals.
840+
using the <literal>ESCAPE</literal> clause. To match the escape
841+
character itself, write two escape characters.
842+
</para>
843+
844+
<para>
845+
Note that the backslash already has a special meaning in string
846+
literals, so to write a pattern constant that contains a backslash
847+
you must write two backslashes in the query. You can avoid this by
848+
selecting a different escape character with <literal>ESCAPE</literal>.
843849
</para>
844850

845851
<para>
846852
The keyword <token>ILIKE</token> can be used instead of
847853
<token>LIKE</token> to make the match case insensitive according
848-
to the active locale. This is a
854+
to the active locale. This isnot in the SQL standard but isa
849855
<productname>Postgres</productname> extension.
850856
</para>
851857

852858
<para>
853859
The operator <literal>~~</literal> is equivalent to
854-
<function>LIKE</function>, <literal>~~*</literal> corresponds to
855-
<literal>ILIKE</literal>.Finally, there are also
856-
<literal>!~~</literal> and <literal>!~~*</literal> operatorsto
860+
<function>LIKE</function>,and<literal>~~*</literal> corresponds to
861+
<function>ILIKE</function>.There are also
862+
<literal>!~~</literal> and <literal>!~~*</literal> operatorsthat
857863
represent <function>NOT LIKE</function> and <function>NOT
858864
ILIKE</function>. All of these are also
859865
<productname>Postgres</productname>-specific.
@@ -864,25 +870,6 @@
864870
<sect2 id="functions-regexp">
865871
<title>POSIX Regular Expressions</title>
866872

867-
<para>
868-
POSIX regular expressions provide a more powerful means for
869-
pattern matching than the <function>LIKE</function> function.
870-
Many Unix tools such as <command>egrep</command>,
871-
<command>sed</command>, or <command>awk</command> use a pattern
872-
matching language that is similar to the one described here.
873-
</para>
874-
875-
<para>
876-
A regular expression is a character sequence that is an
877-
abbreviated definition of a set of strings (a <firstterm>regular
878-
set</firstterm>). A string is said to match a regular expression
879-
if it is a member of the regular set described by the regular
880-
expression. Unlike the <function>LIKE</function> operator, a
881-
regular expression also matches anywhere within a string, unless
882-
the regular expression is explicitly anchored to the beginning or
883-
end of the string.
884-
</para>
885-
886873
<table>
887874
<title>Regular Expression Match Operators</title>
888875

@@ -920,15 +907,38 @@
920907
</tgroup>
921908
</table>
922909

910+
<para>
911+
POSIX regular expressions provide a more powerful means for
912+
pattern matching than the <function>LIKE</function> function.
913+
Many Unix tools such as <command>egrep</command>,
914+
<command>sed</command>, or <command>awk</command> use a pattern
915+
matching language that is similar to the one described here.
916+
</para>
917+
918+
<para>
919+
A regular expression is a character sequence that is an
920+
abbreviated definition of a set of strings (a <firstterm>regular
921+
set</firstterm>). A string is said to match a regular expression
922+
if it is a member of the regular set described by the regular
923+
expression. As with <function>LIKE</function>, pattern characters
924+
match string characters exactly unless they are special characters
925+
in the regular expression language --- but regular expressions use
926+
different special characters than <function>LIKE</function> does.
927+
Unlike <function>LIKE</function> patterns, a
928+
regular expression is allowed to match anywhere within a string, unless
929+
the regular expression is explicitly anchored to the beginning or
930+
end of the string.
931+
</para>
932+
923933

924934
<!-- derived from the re_format.7 man page -->
925935
<para>
926936
Regular expressions (<quote>RE</quote>s), as defined in POSIX
927937
1003.2, come in two forms: modern REs (roughly those of
928938
<command>egrep</command>; 1003.2 calls these
929939
<quote>extended</quote> REs) and obsolete REs (roughly those of
930-
<command>ed</command>; 1003.2 <quote>basic</quote> REs). Obsolete
931-
REs are not available in<productname>Postgres</productname>.
940+
<command>ed</command>; 1003.2 <quote>basic</quote> REs).
941+
<productname>Postgres</productname> implements the modern form.
932942
</para>
933943

934944
<para>
@@ -1004,6 +1014,13 @@
10041014
<literal>\</literal>.
10051015
</para>
10061016

1017+
<para>
1018+
Note that the backslash (<literal>\</literal>) already has a special
1019+
meaning in string
1020+
literals, so to write a pattern constant that contains a backslash
1021+
you must write two backslashes in the query.
1022+
</para>
1023+
10071024
<para>
10081025
A <firstterm>bracket expression</firstterm> is a list of
10091026
characters enclosed in <literal>[]</literal>. It normally matches

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp