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
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
169b152f
Commit
169b152f
authored
6 years ago
by
Paul Sokolovsky
Committed by
Damien George
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
docs/ure: Fully describe supported syntax subset, add example.
parent
1db55381
Branches
Branches containing commit
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
+74
-20
74 additions, 20 deletions
docs/library/ure.rst
with
74 additions
and
20 deletions
docs/library/ure.rst
+
74
−
20
View file @
169b152f
...
...
@@ -10,47 +10,101 @@ 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:
Supported operators
and special sequences
are:
``
'.'
``
``
.
``
Match any character.
``
'
[...]
'
``
``[...]``
Match set of characters. Individual characters and ranges are supported,
including negated sets (e.g. ``[^a-c]``).
``
'^'
``
``
^
``
Match the start of the string.
``
'$'
``
``
$
``
Match the end of the string.
``
'?'
``
Match zero or one of the previous
entity
.
``
?
``
Match zero or one of the previous
sub-pattern
.
``
'*'
``
Match zero or more of the previous
entity
.
``
*
``
Match zero or more of the previous
sub-pattern
.
``
'+'
``
Match one or more of the previous
entity
.
``
+
``
Match one or more of the previous
sub-pattern
.
``'??'``
``??``
Non-greedy version of ``?``, match zero or one, with the preference
for zero.
``'*?'``
``*?``
Non-greedy version of ``*``, match zero or more, with the preference
for the shortest match.
``'+?'``
``+?``
Non-greedy version of ``+``, match one or more, with the preference
for the shortest match.
``'|'``
Match either the LHS or the RHS of this operator.
``|``
Match either the left-hand side or the right-hand side sub-patterns of
this operator.
``
'
(...)
'
``
``(...)``
Grouping. Each group is capturing (a substring it captures can be accessed
with `match.group()` method).
**NOT SUPPORTED**: Counted repetitions (``{m,n}``), more advanced assertions
(``\b``, ``\B``), named groups (``(?P<name>...)``), non-capturing groups
(``(?:...)``), etc.
``\d``
Matches digit. Equivalent to ``[0-9]``.
``\D``
Matches non-digit. Equivalent to ``[^0-9]``.
``\s``
Matches whitespace. Equivalent to ``[ \t-\r]``.
``\S``
Matches non-whitespace. Equivalent to ``[^ \t-\r]``.
``\w``
Matches "word characters" (ASCII only). Equivalent to ``[A-Za-z0-9_]``.
``\W``
Matches non "word characters" (ASCII only). Equivalent to ``[^A-Za-z0-9_]``.
``\``
Escape character. Any other character following the backslash, except
for those listed above, is taken literally. For example, ``\*`` is
equivalent to literal ``*`` (not treated as the ``*`` operator).
Note that ``\r``, ``\n``, etc. are not handled specially, and will be
equivalent to literal letters ``r``, ``n``, etc. Due to this, it's
not recommended to use raw Python strings (``r""``) for regular
expressions. For example, ``r"\r\n"`` when used as the regular
expression is equivalent to ``"rn"``. To match CR character followed
by LF, use ``"\r\n"``.
**NOT SUPPORTED**:
* counted repetitions (``{m,n}``)
* named groups (``(?P<name>...)``)
* non-capturing groups (``(?:...)``)
* more advanced assertions (``\b``, ``\B``)
* special character escapes like ``\r``, ``\n`` - use Python's own escaping
instead
* etc.
Example::
import ure
# As ure doesn't support escapes itself, use of r"" strings is not
# recommended.
regex = ure.compile("[\r\n]")
regex.split("line1\rline2\nline3\r\n")
# Result:
# ['line1', 'line2', 'line3', '', '']
Functions
---------
...
...
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