LEFT | RIGHT |
1 # | 1 # |
2 # Secret Labs' Regular Expression Engine | 2 # Secret Labs' Regular Expression Engine |
3 # | 3 # |
4 # re-compatible interface for the sre matching engine | 4 # re-compatible interface for the sre matching engine |
5 # | 5 # |
6 # Copyright (c) 1998-2001 by Secret Labs AB. All rights reserved. | 6 # Copyright (c) 1998-2001 by Secret Labs AB. All rights reserved. |
7 # | 7 # |
8 # This version of the SRE library can be redistributed under CNRI's | 8 # This version of the SRE library can be redistributed under CNRI's |
9 # Python 1.6 license. For any other use, please contact Secret Labs | 9 # Python 1.6 license. For any other use, please contact Secret Labs |
10 # AB (info@pythonware.com). | 10 # AB (info@pythonware.com). |
(...skipping 26 matching lines...) Expand all Loading... |
37 "?" Matches 0 or 1 (greedy) of the preceding RE. | 37 "?" Matches 0 or 1 (greedy) of the preceding RE. |
38 *?,+?,?? Non-greedy versions of the previous three special characters. | 38 *?,+?,?? Non-greedy versions of the previous three special characters. |
39 {m,n} Matches from m to n repetitions of the preceding RE. | 39 {m,n} Matches from m to n repetitions of the preceding RE. |
40 {m,n}? Non-greedy version of the above. | 40 {m,n}? Non-greedy version of the above. |
41 "\\" Either escapes special characters or signals a special sequence. | 41 "\\" Either escapes special characters or signals a special sequence. |
42 [] Indicates a set of characters. | 42 [] Indicates a set of characters. |
43 A "^" as the first character indicates a complementing set. | 43 A "^" as the first character indicates a complementing set. |
44 "|" A|B, creates an RE that will match either A or B. | 44 "|" A|B, creates an RE that will match either A or B. |
45 (...) Matches the RE inside the parentheses. | 45 (...) Matches the RE inside the parentheses. |
46 The contents can be retrieved or matched later in the string. | 46 The contents can be retrieved or matched later in the string. |
47 (?iLmsux) Set the I, L, M, S, U, or X flag for the RE (see below). | 47 (?aiLmsux) Set the A, I, L, M, S, U, or X flag for the RE (see below). |
48 (?:...) Non-grouping version of regular parentheses. | 48 (?:...) Non-grouping version of regular parentheses. |
49 (?P<name>...) The substring matched by the group is accessible by name. | 49 (?P<name>...) The substring matched by the group is accessible by name. |
50 (?P=name) Matches the text matched earlier by the group named name. | 50 (?P=name) Matches the text matched earlier by the group named name. |
51 (?#...) A comment; ignored. | 51 (?#...) A comment; ignored. |
52 (?=...) Matches if ... matches next, but doesn't consume the string. | 52 (?=...) Matches if ... matches next, but doesn't consume the string. |
53 (?!...) Matches if ... doesn't match next. | 53 (?!...) Matches if ... doesn't match next. |
54 (?<=...) Matches if preceded by ... (must be fixed length). | 54 (?<=...) Matches if preceded by ... (must be fixed length). |
55 (?<!...) Matches if not preceded by ... (must be fixed length). | 55 (?<!...) Matches if not preceded by ... (must be fixed length). |
56 (?(id/name)yes|no) Matches yes pattern if the group with id/name matched, | 56 (?(id/name)yes|no) Matches yes pattern if the group with id/name matched, |
57 the (optional) no pattern otherwise. | 57 the (optional) no pattern otherwise. |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 if i == j: | 325 if i == j: |
326 break | 326 break |
327 action = self.lexicon[m.lastindex-1][1] | 327 action = self.lexicon[m.lastindex-1][1] |
328 if hasattr(action, '__call__'): | 328 if hasattr(action, '__call__'): |
329 self.match = m | 329 self.match = m |
330 action = action(self, m.group()) | 330 action = action(self, m.group()) |
331 if action is not None: | 331 if action is not None: |
332 append(action) | 332 append(action) |
333 i = j | 333 i = j |
334 return result, string[i:] | 334 return result, string[i:] |
LEFT | RIGHT |