Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2 | daniel-mar | 1 | <div id="global_content"> |
2 | <div id="reg_in_regexp"> |
||
3 | |||
4 | <table cellspacing="0" cellpadding="0" border="0" width="100%"> |
||
5 | <tr> |
||
6 | <td height="6%" valign="top" width="100%"> |
||
7 | <span class="page_title"> |
||
8 | Regular expressions |
||
9 | </span> |
||
10 | </td> |
||
11 | </tr> |
||
12 | </table><br><a name="introduction"></a> |
||
13 | <table cellspacing="0" cellpadding="0" border="0" width="100%"> |
||
14 | <tr> |
||
15 | <td height="8%" valign="middle" width="100%"><span class="section_title">Introduction</span></td> |
||
16 | </tr> |
||
17 | </table> |
||
18 | <table cellspacing="0" cellpadding="0" border="0" width="100%"> |
||
19 | <tr> |
||
20 | <td valign="top" width="100%"> |
||
21 | |||
22 | <p> |
||
23 | A regular expression is a character sequence that is an abbreviated |
||
24 | definition of a set of strings. A string is said to match a regular |
||
25 | expression if it is a member of the set described by the regular expression. |
||
26 | </p> |
||
27 | <p> |
||
28 | A regular expression is allowed to match anywhere within a string, |
||
29 | unless the regular expression is explicitly anchored to the beginning |
||
30 | or end of the string (by using operators <code>^</code> and/or <code>$</code>). |
||
31 | </p> |
||
32 | |||
33 | </td> |
||
34 | |||
35 | |||
36 | |||
37 | <td width="3%" valign="top"> </td> |
||
38 | |||
39 | |||
40 | |||
41 | <td width="20%"> </td> |
||
42 | |||
43 | |||
44 | |||
45 | </tr> |
||
46 | |||
47 | |||
48 | |||
49 | </table> |
||
50 | |||
51 | <a name="syntax"></a> |
||
52 | <table cellspacing="0" cellpadding="0" border="0" width="100%"> |
||
53 | |||
54 | |||
55 | |||
56 | <tr> |
||
57 | |||
58 | |||
59 | |||
60 | |||
61 | |||
62 | |||
63 | <td height="8%" valign="middle" width="100%"><span class="section_title">Syntax</span></td> |
||
64 | |||
65 | |||
66 | |||
67 | |||
68 | |||
69 | </tr> |
||
70 | |||
71 | |||
72 | |||
73 | </table> |
||
74 | |||
75 | |||
76 | |||
77 | <table cellspacing="0" cellpadding="0" border="0" width="100%"> |
||
78 | |||
79 | |||
80 | |||
81 | <tr> |
||
82 | |||
83 | |||
84 | |||
85 | |||
86 | |||
87 | |||
88 | <td valign="top" width="100%"> |
||
89 | <p>The following character sequences are recognized:</p> |
||
90 | <ul> |
||
91 | <li> |
||
92 | <code class="code">.</code> matches any single character except |
||
93 | newline |
||
94 | </li> |
||
95 | <li> |
||
96 | <code class="code">*</code> (postfix) matches the previous expression |
||
97 | zero, one or several times |
||
98 | </li> |
||
99 | <li> |
||
100 | <code class="code">+</code> (postfix) matches the previous expression |
||
101 | one or several times |
||
102 | <ul> |
||
103 | <li><code>[+]</code> matches a "+" character (escape mechanism)</li> |
||
104 | </ul> |
||
105 | </li> |
||
106 | <li> |
||
107 | <code class="code">?</code> (postfix) matches the previous expression |
||
108 | once or not at all |
||
109 | </li> |
||
110 | <li> |
||
111 | <code class="code">[ ]</code> is a character set |
||
112 | <ul> |
||
113 | <li> |
||
114 | ranges are denoted with a hyphen "<code class="code">-</code>", |
||
115 | as in <code class="code">[a-z]</code> |
||
116 | </li> |
||
117 | <li> |
||
118 | an initial caret "<code class="code">^</code>", as in <code class="code">[^0-9]</code>, |
||
119 | complements the set (i.e., any character, except a lowercase letter from a to z, is accepted) |
||
120 | </li> |
||
121 | <li><code>[[]</code> matches a "[" character (escape mechanism)</li> |
||
122 | <li><code>[]]</code> matches a "]" character (escape mechanism)</li> |
||
123 | </ul> |
||
124 | </li> |
||
125 | <li><code class="code">^</code> matches at beginning of line</li> |
||
126 | <li><code class="code">$</code> matches at end of line</li> |
||
127 | <li><code class="code">|</code> (infix) alternative between two expressions</li> |
||
128 | <li> |
||
129 | <code class="code">( )</code> grouping of the enclosed expression |
||
130 | <ul> |
||
131 | <li><code>[(]</code> matches a "(" character (escape mechanism)</li> |
||
132 | <li><code>[)]</code> matches a ")" character (escape mechanism)</li> |
||
133 | </ul> |
||
134 | </li> |
||
135 | <li> |
||
136 | <code class="code">\</code> escapes special characters (<em>i.e.</em>, |
||
137 | <code>^.[$|*?{'</code>): |
||
138 | <ul> |
||
139 | <li><code>\n</code> matches a newline character</li> |
||
140 | <li><code>\.</code> matches a dot "." character</li> |
||
141 | <li><code>\'</code> matches a quote "<code>'</code>" character</li> |
||
142 | <li> |
||
143 | <code class="code">\</code> cannot be escaped; to search for |
||
144 | a backslash, use <code class="code">.</code> to match any single |
||
145 | character |
||
146 | </li> |
||
147 | </ul> |
||
148 | </li> |
||
149 | </ul> |
||
150 | </td> |
||
151 | <td width="2%" valign="top"> </td> |
||
152 | <td width="20%"> </td> |
||
153 | </tr> |
||
154 | </table> |
||
155 | |||
156 | </div> |
||
157 | <div class="clear"></div> |
||
158 | </div> |