blob: f20dff6f39ba94095e27ab8c2dbe35d980b4295c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
:mod:`ure` -- regular expressions
=================================
.. module:: ure
:synopsis: regular expressions
This module implements regular expression operations. Regular expression
syntax supported is a subset of CPython ``re`` module (and actually is
a subset of POSIX extended regular expressions).
Supported operators are:
``'.'``
Match any character.
``'[]'``
Match set of characters. Individual characters and ranges are supported.
``'^'``
``'$'``
``'?'``
``'*'``
``'+'``
``'??'``
``'*?'``
``'+?'``
Counted repetitions (``{m,n}``), more advanced assertions, names groups,
etc. are not supported.
Functions
---------
.. function:: compile(regex)
Compile regular expression, return ``regex`` object.
.. function:: match(regex, string)
Match ``regex`` against ``string``. Match always happens from starting
position in a string.
.. function:: search(regex, string)
Search ``regex`` in a ``string``. Unlike ``match``, this will search
string for first position which matches regex (which still may be
0 if regex is anchored).
.. data:: DEBUG
Flag value, display debug information about compiled expression.
Regex objects
-------------
Compiled regular expression. Instances of this class are created using
``ure.compile()``.
.. method:: regex.match(string)
.. method:: regex.search(string)
.. method:: regex.split(string, max_split=-1)
Match objects
-------------
Match objects as returned by ``match()`` and ``search()`` methods.
.. method:: match.group([index])
Only numeric groups are supported.
|