-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: shifter <shifter@axoflow.com>
- Loading branch information
Showing
1 changed file
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
`regex_subst()`: Function Reworked | ||
|
||
The `regex_subst()` function has been updated to enhance functionality: | ||
|
||
- **Extended Match Group Support**: | ||
Replacement strings can now resolve match group references up to 999 groups. | ||
|
||
- **Optional Disabling**: | ||
The feature can be disabled using the `nogroups` named argument flag. | ||
|
||
- **Leading Zero Support**: | ||
Match group references with leading zeros (e.g., `\01`, `\002`) are now correctly interpreted. This prevents ambiguity when parsing group IDs, ensuring that shorter IDs like `\1` are not mistakenly interpreted as part of larger numbers like `\12`. | ||
|
||
**Example**: | ||
|
||
```python | ||
result = regex_subst("baz,foo,bar", /(\w+),(\w+),(\w+)/, "\\2 \\03 \\1") | ||
|
||
# Force disable this feature | ||
result = regex_subst("baz,foo,bar", /(\w+),(\w+),(\w+)/, "\\2 \\03 \\1", nogroups=True) | ||
|
||
# Handling leading zeros | ||
result = regex_subst("baz,foo,bar", /(\w+),(\w+),(\w+)/, "\\0010") # returns `baz0` | ||
``` |