Skip to content

Commit

Permalink
news: add entry for regexp-subst
Browse files Browse the repository at this point in the history
Signed-off-by: shifter <shifter@axoflow.com>
  • Loading branch information
bshifter committed Dec 12, 2024
1 parent 231c51a commit ac6df5a
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions news/fx-feature-409.md
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`
```

0 comments on commit ac6df5a

Please sign in to comment.