Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
d80ecad0
Commit
d80ecad0
authored
Jul 1, 2017
by
Paul Sokolovsky
Browse files
Options
Downloads
Patches
Plain Diff
docs/ure: Elaborate doc, update markup to the latest conventions.
parent
d42bb58c
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
docs/library/ure.rst
+26
-13
26 additions, 13 deletions
docs/library/ure.rst
with
26 additions
and
13 deletions
docs/library/ure.rst
+
26
−
13
View file @
d80ecad0
:mod:`ure` -- regular expressions
:mod:`ure` --
simple
regular expressions
=================================
=================================
=======
.. module:: ure
.. module:: ure
:synopsis: regular expressions
:synopsis: regular expressions
...
@@ -32,6 +32,10 @@ Supported operators are:
...
@@ -32,6 +32,10 @@ Supported operators are:
``'+?'``
``'+?'``
``'()'``
Grouping. Each group is capturing (a substring it captures can be accessed
with `match.group()` method).
Counted repetitions (``{m,n}``), more advanced assertions, named groups,
Counted repetitions (``{m,n}``), more advanced assertions, named groups,
etc. are not supported.
etc. are not supported.
...
@@ -39,18 +43,18 @@ etc. are not supported.
...
@@ -39,18 +43,18 @@ etc. are not supported.
Functions
Functions
---------
---------
.. function:: compile(regex)
.. function:: compile(regex
_str
)
Compile regular expression, return
`
`regex
`
` object.
Compile regular expression, return `regex
<regex>
` object.
.. function:: match(regex, string)
.. function:: match(regex
_str
, string)
Match ``regex``
against
``
string
``
. Match always happens
from starting
Compile *regex_str* and match
against
*
string
*
. Match always happens
position in a string.
from starting
position in a string.
.. function:: search(regex, string)
.. function:: search(regex
_str
, string)
Search ``regex``
in a
``
string
``
. Unlike
`
`match`
`
, this will search
Compile *regex_str* and search it
in a
*
string
*
. Unlike `match`, this will search
string for first position which matches regex (which still may be
string for first position which matches regex (which still may be
0 if regex is anchored).
0 if regex is anchored).
...
@@ -59,24 +63,33 @@ Functions
...
@@ -59,24 +63,33 @@ Functions
Flag value, display debug information about compiled expression.
Flag value, display debug information about compiled expression.
.. _regex:
Regex objects
Regex objects
-------------
-------------
Compiled regular expression. Instances of this class are created using
Compiled regular expression. Instances of this class are created using
`
`ure.compile()`
`
.
`ure.compile()`.
.. method:: regex.match(string)
.. method:: regex.match(string)
regex.search(string)
.. method:: regex.search(string)
Similar to the module-level functions :meth:`match` and :meth:`search`.
Using methods is (much) more efficient if the same regex is applied to
multiple strings.
.. method:: regex.split(string, max_split=-1)
.. method:: regex.split(string, max_split=-1)
Split a *string* using regex. If *max_split* is given, it specifies
maximum number of splits to perform. Returns list of strings (there
may be up to *max_split+1* elements if it's specified).
Match objects
Match objects
-------------
-------------
Match objects as returned by
`
`match()`
`
and
`
`search()`
`
methods.
Match objects as returned by `match()` and `search()` methods.
.. method:: match.group([index])
.. method:: match.group([index])
Only numeric groups are supported.
Return matching (sub)string. *index* is 0 for entire match,
1 and above for each capturing group. Only numeric groups are supported.
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment