Python has its own regular expression engine (built-in re module), but the supported features are thin, and none of the following features are supported:
- Curing Group Atomic Grouping
- Occupy priority quantifier possessive quantifiers
- Variable length reverse-order surround Variable-length Lookbehind
- Recursive matching Recursive patterns
Matthew Barnett wrote a more powerful regular expression engine-theregex module for Python-that could replace the built-in re module. In addition to some of the features mentioned above, there are many new things.
Let's start with the Regex installation, which you can do at the command line:
Install Regex
The regex is divided into version 0 and version 1 Two working modes, where version 0 is compatible with existing RE modules:
|
Version 0 (re-module compatible) |
Version 1 |
Enable method |
Set up. VERSION0 or. V0 flag, or write in an expression (? V0). If no settings are made, the default is version 0. |
Set up. VERSION1 or. V1 flag, or write in an expression (? V1). |
Behavior of the. Split () |
You cannot cut a string at a 0 wide match . |
You can cut a string at a 0 wide match . |
0 wide Match |
Treated like re. |
Handled like Perl and PCRE . |
The identity inside the expression |
Only works on the entire expression and cannot be closed. |
Can be applied to an entire or partial expression and can be closed. |
Character groups |
Only simple character groups are supported. |
Groups of characters can have nested sets, or can do set operations (set, intersection, difference set, symmetric difference set). |
Character case |
Only simple case is supported by default. |
The capitalization of all Unicode characters is supported by default. |
Python's Regex module--a more powerful regular expression engine (not yet ready to write)