1- :mod: `ure ` -- regular expressions
2- =================================
1+ :mod: `ure ` -- simple regular expressions
2+ ========================================
33
44.. module :: ure
55 :synopsis: regular expressions
@@ -32,25 +32,29 @@ Supported operators are:
3232
3333``'+?' ``
3434
35+ ``'()' ``
36+ Grouping. Each group is capturing (a substring it captures can be accessed
37+ with `match.group() ` method).
38+
3539Counted repetitions (``{m,n} ``), more advanced assertions, named groups,
3640etc. are not supported.
3741
3842
3943Functions
4044---------
4145
42- .. function :: compile(regex )
46+ .. function :: compile(regex_str )
4347
44- Compile regular expression, return `` regex ` ` object.
48+ Compile regular expression, return `regex <regex> ` object.
4549
46- .. function :: match(regex , string)
50+ .. function :: match(regex_str , string)
4751
48- Match `` regex `` against `` string `` . Match always happens from starting
49- position in a string.
52+ Compile * regex_str * and match against * string * . Match always happens
53+ from starting position in a string.
5054
51- .. function :: search(regex , string)
55+ .. function :: search(regex_str , string)
5256
53- Search `` regex `` in a `` string `` . Unlike `` match ` `, this will search
57+ Compile * regex_str * and search it in a * string * . Unlike `match `, this will search
5458 string for first position which matches regex (which still may be
5559 0 if regex is anchored).
5660
@@ -59,24 +63,33 @@ Functions
5963 Flag value, display debug information about compiled expression.
6064
6165
66+ .. _regex :
67+
6268Regex objects
6369-------------
6470
6571Compiled regular expression. Instances of this class are created using
66- `` ure.compile() ` `.
72+ `ure.compile() `.
6773
6874.. method :: regex.match(string)
75+ regex.search(string)
6976
70- .. method :: regex.search(string)
77+ Similar to the module-level functions :meth: `match ` and :meth: `search `.
78+ Using methods is (much) more efficient if the same regex is applied to
79+ multiple strings.
7180
7281.. method :: regex.split(string, max_split=-1)
7382
83+ Split a *string * using regex. If *max_split * is given, it specifies
84+ maximum number of splits to perform. Returns list of strings (there
85+ may be up to *max_split+1 * elements if it's specified).
7486
7587Match objects
7688-------------
7789
78- Match objects as returned by `` match() `` and `` search() ` ` methods.
90+ Match objects as returned by `match() ` and `search() ` methods.
7991
8092.. method :: match.group([index])
8193
82- Only numeric groups are supported.
94+ Return matching (sub)string. *index * is 0 for entire match,
95+ 1 and above for each capturing group. Only numeric groups are supported.
0 commit comments