Skip to content

Commit 3a5352b

Browse files
committed
docs: Add skeleton docs for ure module.
1 parent cd97a43 commit 3a5352b

2 files changed

Lines changed: 83 additions & 0 deletions

File tree

docs/library/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ it will fallback to loading the built-in ``ujson`` module.
4242
uhashlib.rst
4343
uheapq.rst
4444
ujson.rst
45+
ure.rst
4546
usocket.rst
4647

4748
Libraries specific to the pyboard

docs/library/ure.rst

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

0 commit comments

Comments
 (0)