grep-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Changes to manual/html_node/Character-Classes-and-Bracket-Expressions.ht


From: Karl Berry
Subject: Changes to manual/html_node/Character-Classes-and-Bracket-Expressions.html
Date: Sun, 24 May 2009 18:43:06 +0000

CVSROOT:        /web/grep
Module name:    grep
Changes by:     Karl Berry <karl>       09/05/24 18:43:01

Index: manual/html_node/Character-Classes-and-Bracket-Expressions.html
===================================================================
RCS file: manual/html_node/Character-Classes-and-Bracket-Expressions.html
diff -N manual/html_node/Character-Classes-and-Bracket-Expressions.html
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ manual/html_node/Character-Classes-and-Bracket-Expressions.html     24 May 
2009 18:42:58 -0000      1.1
@@ -0,0 +1,156 @@
+<html lang="en">
+<head>
+<title>Character Classes and Bracket Expressions - GNU Grep 2.5.4</title>
+<meta http-equiv="Content-Type" content="text/html">
+<meta name="description" content="GNU Grep 2.5.4">
+<meta name="generator" content="makeinfo 4.13">
+<link title="Top" rel="start" href="index.html#Top">
+<link rel="up" href="Regular-Expressions.html#Regular-Expressions" 
title="Regular Expressions">
+<link rel="prev" href="Fundamental-Structure.html#Fundamental-Structure" 
title="Fundamental Structure">
+<link rel="next" 
href="The-Backslash-Character-and-Special-Expressions.html#The-Backslash-Character-and-Special-Expressions"
 title="The Backslash Character and Special Expressions">
+<link href="http://www.gnu.org/software/texinfo/"; rel="generator-home" 
title="Texinfo Homepage">
+<!--
+This manual is for `grep', a pattern matching engine.
+
+Copyright (C) 1999, 2000, 2001, 2002, 2005, 2008, 2009 Free
+Software Foundation, Inc.
+
+     Permission is granted to copy, distribute and/or modify this
+     document under the terms of the GNU Free Documentation License,
+     Version 1.3 or any later version published by the Free Software
+     Foundation; with no Invariant Sections, with no Front-Cover Texts,
+     and with no Back-Cover Texts.  A copy of the license is included
+     in the section entitled ``GNU Free Documentation License''.
+   -->
+<meta http-equiv="Content-Style-Type" content="text/css">
+<style type="text/css"><!--
+  pre.display { font-family:inherit }
+  pre.format  { font-family:inherit }
+  pre.smalldisplay { font-family:inherit; font-size:smaller }
+  pre.smallformat  { font-family:inherit; font-size:smaller }
+  pre.smallexample { font-size:smaller }
+  pre.smalllisp    { font-size:smaller }
+  span.sc    { font-variant:small-caps }
+  span.roman { font-family:serif; font-weight:normal; } 
+  span.sansserif { font-family:sans-serif; font-weight:normal; } 
+--></style>
+</head>
+<body>
+<div class="node">
+<a name="Character-Classes-and-Bracket-Expressions"></a>
+<p>
+Next:&nbsp;<a rel="next" accesskey="n" 
href="The-Backslash-Character-and-Special-Expressions.html#The-Backslash-Character-and-Special-Expressions">The
 Backslash Character and Special Expressions</a>,
+Previous:&nbsp;<a rel="previous" accesskey="p" 
href="Fundamental-Structure.html#Fundamental-Structure">Fundamental 
Structure</a>,
+Up:&nbsp;<a rel="up" accesskey="u" 
href="Regular-Expressions.html#Regular-Expressions">Regular Expressions</a>
+<hr>
+</div>
+
+<h3 class="section">3.2 Character Classes and Bracket Expressions</h3>
+
+<p><a name="index-bracket-expression-203"></a><a 
name="index-character-class-204"></a>A <dfn>bracket expression</dfn> is a list 
of characters enclosed by &lsquo;<samp><span 
class="samp">[</span></samp>&rsquo; and
+&lsquo;<samp><span class="samp">]</span></samp>&rsquo;. 
+It matches any single character in that list;
+if the first character of the list is the caret &lsquo;<samp><span 
class="samp">^</span></samp>&rsquo;,
+then it matches any character <strong>not</strong> in the list. 
+For example, the regular expression
+&lsquo;<samp><span class="samp">[0123456789]</span></samp>&rsquo; matches any 
single digit.
+
+   <p><a name="index-range-expression-205"></a>Within a bracket expression, a 
<dfn>range expression</dfn> consists of two
+characters separated by a hyphen. 
+It matches any single character that
+sorts between the two characters, inclusive, using the locale's
+collating sequence and character set. 
+For example, in the default C
+locale, &lsquo;<samp><span class="samp">[a-d]</span></samp>&rsquo; is 
equivalent to &lsquo;<samp><span class="samp">[abcd]</span></samp>&rsquo;. 
+Many locales sort
+characters in dictionary order, and in these locales &lsquo;<samp><span 
class="samp">[a-d]</span></samp>&rsquo; is
+typically not equivalent to &lsquo;<samp><span 
class="samp">[abcd]</span></samp>&rsquo;;
+it might be equivalent to &lsquo;<samp><span 
class="samp">[aBbCcDd]</span></samp>&rsquo;, for example. 
+To obtain the traditional interpretation
+of bracket expressions, you can use the &lsquo;<samp><span 
class="samp">C</span></samp>&rsquo; locale by setting the
+<samp><span class="env">LC_ALL</span></samp> environment variable to the value 
&lsquo;<samp><span class="samp">C</span></samp>&rsquo;.
+
+   <p>Finally, certain named classes of characters are predefined within
+bracket expressions, as follows. 
+Their interpretation depends on the <code>LC_CTYPE</code> locale;
+the interpretation below is that of the &lsquo;<samp><span 
class="samp">C</span></samp>&rsquo; locale,
+which is the default if no <code>LC_CTYPE</code> locale is specified.
+
+   <p><a name="index-classes-of-characters-206"></a><a 
name="index-character-classes-207"></a>
+     <dl>
+<dt>&lsquo;<samp><span class="samp">[:alnum:]</span></samp>&rsquo;<dd><a 
name="index-alnum-_0040r_007bcharacter-class_007d-208"></a><a 
name="index-alphanumeric-characters-209"></a>Alphanumeric characters:
+&lsquo;<samp><span class="samp">[:alpha:]</span></samp>&rsquo; and 
&lsquo;<samp><span class="samp">[:digit:]</span></samp>&rsquo;.
+
+     <br><dt>&lsquo;<samp><span 
class="samp">[:alpha:]</span></samp>&rsquo;<dd><a 
name="index-alpha-_0040r_007bcharacter-class_007d-210"></a><a 
name="index-alphabetic-characters-211"></a>Alphabetic characters:
+&lsquo;<samp><span class="samp">[:lower:]</span></samp>&rsquo; and 
&lsquo;<samp><span class="samp">[:upper:]</span></samp>&rsquo;.
+
+     <br><dt>&lsquo;<samp><span 
class="samp">[:blank:]</span></samp>&rsquo;<dd><a 
name="index-blank-_0040r_007bcharacter-class_007d-212"></a><a 
name="index-blank-characters-213"></a>Blank characters:
+space and tab.
+
+     <br><dt>&lsquo;<samp><span 
class="samp">[:cntrl:]</span></samp>&rsquo;<dd><a 
name="index-cntrl-_0040r_007bcharacter-class_007d-214"></a><a 
name="index-control-characters-215"></a>Control characters. 
+In <span class="sc">ascii</span>, these characters have octal codes 000
+through 037, and 177 (<code>DEL</code>). 
+In other character sets, these are
+the equivalent characters, if any.
+
+     <br><dt>&lsquo;<samp><span 
class="samp">[:digit:]</span></samp>&rsquo;<dd><a 
name="index-digit-_0040r_007bcharacter-class_007d-216"></a><a 
name="index-digit-characters-217"></a><a 
name="index-numeric-characters-218"></a>Digits: <code>0 1 2 3 4 5 6 7 8 
9</code>.
+
+     <br><dt>&lsquo;<samp><span 
class="samp">[:graph:]</span></samp>&rsquo;<dd><a 
name="index-graph-_0040r_007bcharacter-class_007d-219"></a><a 
name="index-graphic-characters-220"></a>Graphical characters:
+&lsquo;<samp><span class="samp">[:alnum:]</span></samp>&rsquo; and 
&lsquo;<samp><span class="samp">[:punct:]</span></samp>&rsquo;.
+
+     <br><dt>&lsquo;<samp><span 
class="samp">[:lower:]</span></samp>&rsquo;<dd><a 
name="index-lower-_0040r_007bcharacter-class_007d-221"></a><a 
name="index-lower_002dcase-letters-222"></a>Lower-case letters:
+<code>a b c d e f g h i j k l m n o p q r s t u v w x y z</code>.
+
+     <br><dt>&lsquo;<samp><span 
class="samp">[:print:]</span></samp>&rsquo;<dd><a 
name="index-print-_0040r_007bcharacter-class_007d-223"></a><a 
name="index-printable-characters-224"></a>Printable characters:
+&lsquo;<samp><span class="samp">[:alnum:]</span></samp>&rsquo;, 
&lsquo;<samp><span class="samp">[:punct:]</span></samp>&rsquo;, and space.
+
+     <br><dt>&lsquo;<samp><span 
class="samp">[:punct:]</span></samp>&rsquo;<dd><a 
name="index-punct-_0040r_007bcharacter-class_007d-225"></a><a 
name="index-punctuation-characters-226"></a>Punctuation characters:
+<code>! " # $ % &amp; ' ( ) * + , - . / : ; &lt; = &gt; ? @ [ \ ] ^ _ ` { | } 
~</code>.
+
+     <br><dt>&lsquo;<samp><span 
class="samp">[:space:]</span></samp>&rsquo;<dd><a 
name="index-space-_0040r_007bcharacter-class_007d-227"></a><a 
name="index-space-characters-228"></a><a 
name="index-whitespace-characters-229"></a>Space characters:
+tab, newline, vertical tab, form feed, carriage return, and space.
+
+     <br><dt>&lsquo;<samp><span 
class="samp">[:upper:]</span></samp>&rsquo;<dd><a 
name="index-upper-_0040r_007bcharacter-class_007d-230"></a><a 
name="index-upper_002dcase-letters-231"></a>Upper-case letters:
+<code>A B C D E F G H I J K L M N O P Q R S T U V W X Y Z</code>.
+
+     <br><dt>&lsquo;<samp><span 
class="samp">[:xdigit:]</span></samp>&rsquo;<dd><a 
name="index-xdigit-_0040r_007bcharacter-class_007d-232"></a><a 
name="index-xdigit-class-233"></a><a 
name="index-hexadecimal-digits-234"></a>Hexadecimal digits:
+<code>0 1 2 3 4 5 6 7 8 9 A B C D E F a b c d e f</code>.
+
+   </dl>
+   For example, &lsquo;<samp><span 
class="samp">[[:alnum:]]</span></samp>&rsquo; means &lsquo;<samp><span 
class="samp">[0-9A-Za-z]</span></samp>&rsquo;, except the latter
+depends upon the &lsquo;<samp><span class="samp">C</span></samp>&rsquo; locale 
and the <span class="sc">ascii</span> character
+encoding, whereas the former is independent of locale and character set. 
+(Note that the brackets in these class names are
+part of the symbolic names, and must be included in addition to
+the brackets delimiting the bracket expression.)
+
+   <p>Most meta-characters lose their special meaning inside bracket 
expressions.
+
+     <dl>
+<dt>&lsquo;<samp><span class="samp">]</span></samp>&rsquo;<dd>ends the bracket 
expression if it's not the first list item. 
+So, if you want to make the &lsquo;<samp><span 
class="samp">]</span></samp>&rsquo; character a list item,
+you must put it first.
+
+     <br><dt>&lsquo;<samp><span 
class="samp">[.</span></samp>&rsquo;<dd>represents the open collating symbol.
+
+     <br><dt>&lsquo;<samp><span 
class="samp">.]</span></samp>&rsquo;<dd>represents the close collating symbol.
+
+     <br><dt>&lsquo;<samp><span 
class="samp">[=</span></samp>&rsquo;<dd>represents the open equivalence class.
+
+     <br><dt>&lsquo;<samp><span 
class="samp">=]</span></samp>&rsquo;<dd>represents the close equivalence class.
+
+     <br><dt>&lsquo;<samp><span 
class="samp">[:</span></samp>&rsquo;<dd>represents the open character class 
symbol, and should be followed by a valid character class name.
+
+     <br><dt>&lsquo;<samp><span 
class="samp">:]</span></samp>&rsquo;<dd>represents the close character class 
symbol.
+
+     <br><dt>&lsquo;<samp><span 
class="samp">-</span></samp>&rsquo;<dd>represents the range if it's not first 
or last in a list or the ending point
+of a range.
+
+     <br><dt>&lsquo;<samp><span 
class="samp">^</span></samp>&rsquo;<dd>represents the characters not in the 
list. 
+If you want to make the &lsquo;<samp><span class="samp">^</span></samp>&rsquo;
+character a list item, place it anywhere but first.
+
+   </dl>
+
+   </body></html>
+




reply via email to

[Prev in Thread] Current Thread [Next in Thread]