A little wordsmithing in the pattern-matching section.
authorTom Lane
Sat, 16 Dec 2000 19:33:23 +0000 (19:33 +0000)
committerTom Lane
Sat, 16 Dec 2000 19:33:23 +0000 (19:33 +0000)
doc/src/sgml/func.sgml

index 48bdb2a5e1cf19014f0819d25b3f22b6b8387b30..fdd1c34a3e153b56f2cab6f5c9955309675f3bfd 100644 (file)
@@ -1,4 +1,4 @@
-
+
 
 
  Functions and Operators
 
    
     If pattern does not contain percent
-    signs or underscore then the pattern only represents the string
+    signs or underscore, then the pattern only represents the string
     itself; in that case LIKE acts like the
     equals operator.  An underscore (_) in
     pattern stands for (matches) any single
-    character, a percent sign (%) matches zero or
-    more characters.
+    character; a percent sign (%) matches any string
+    of zero or more characters.
    
 
    
 
    
     LIKE pattern matches always cover the entire
-    string.  On order to match a pattern anywhere within a string, the
+    string.  To match a pattern anywhere within a string, the
     pattern must therefore start and end with a percent sign.
    
 
    
-    In order to match a literal underscore or percent sign, the
-    respective character in pattern must be
-    preceded by the active escape character.  The default escape
+    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 may be selected by
-    using the ESCAPE clause.  When using the
-    backslash as escape character in literal strings it must be
-    doubled, because the backslash already has a special meaning in
-    string literals.
+    using the ESCAPE clause.  To match the escape
+    character itself, write two escape characters.
+   
+
+   
+    Note that the backslash already has a special meaning in string
+    literals, so to write a pattern constant that contains a backslash
+    you must write two backslashes in the query.  You can avoid this by
+    selecting a different escape character with ESCAPE.
    
 
    
     The keyword ILIKE can be used instead of
     LIKE to make the match case insensitive according
-    to the active locale.  This is a
+    to the active locale.  This is not in the SQL standard but is a
     Postgres extension.
    
 
    
     The operator ~~ is equivalent to
-    LIKE~~* corresponds to
-    <literal>ILIKE.  Finally, there are also
-    !~~ and !~~* operators to
+    LIKEand ~~* corresponds to
+    <function>ILIKE.  There are also
+    !~~ and !~~* operators that
     represent NOT LIKE and NOT
     ILIKE.  All of these are also
     Postgres-specific.
   
    POSIX Regular Expressions
 
-   
-    POSIX regular expressions provide a more powerful means for
-    pattern matching than the LIKE function.
-    Many Unix tools such as egrep,
-    sed, or awk use a pattern
-    matching language that is similar to the one described here.
-   
-
-   
-    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.  Unlike the LIKE operator, a
-    regular expression also matches anywhere within a string, unless
-    the regular expression is explicitly anchored to the beginning or
-    end of the string.
-   
-
    
     Regular Expression Match Operators
 
     
    
 
+   
+    POSIX regular expressions provide a more powerful means for
+    pattern matching than the LIKE function.
+    Many Unix tools such as egrep,
+    sed, or awk use a pattern
+    matching language that is similar to the one described here.
+   
+
+   
+    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 LIKE, pattern characters
+    match string characters exactly unless they are special characters
+    in the regular expression language --- but regular expressions use
+    different special characters than LIKE does.
+    Unlike LIKE 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.
+   
+
 
 
    
     1003.2, come in two forms: modern REs (roughly those of
     egrep; 1003.2 calls these
     extended REs) and obsolete REs (roughly those of
-    ed; 1003.2 basic REs).  Obsolete
-    REs are not available in Postgres.
+    ed; 1003.2 basic REs).
+    Postgres implements the modern form.
    
 
    
     \.
    
 
+   
+    Note that the backslash (\) already has a special
+    meaning in string
+    literals, so to write a pattern constant that contains a backslash
+    you must write two backslashes in the query.
+   
+
    
     A bracket expression is a list of
     characters enclosed in [].  It normally matches