T4: Fix Python sub() named groups + add named_group() to PyMatch #41

Open
opened 2026-03-24 22:26:34 +03:00 by NiXTheDev · 0 comments
NiXTheDev commented 2026-03-24 22:26:34 +03:00 (Migrated from github.com)

Task 4: Fix Python Named Groups

Wave: 1 (Critical Bug Fixes)
Category: unspecified-high
Parent: Epic #37

Problem

Python sub() creates empty HashMap for named groups (line 93), so \g{name} in replacements doesn't work. PyMatch also missing named_group() method.

What to do

  • RED: Write failing Python tests for sub() with named backrefs and named_group() method
  • GREEN: Fix ogex-python/src/lib.rs line 93 to pass actual named groups, add named_group() method to PyMatch
  • REFACTOR: Clean up Python bindings

Acceptance Criteria

  • ogex.sub(r"(name:abc)", r"[\g{name}]", "abc") returns "[abc]`
  • match.named_group("name") returns captured group text

Files

  • ogex-python/src/lib.rs:93 — empty HashMap for named groups
  • ogex-python/src/lib.rs:110-183 — PyMatch class

Commit

fix: Python sub() named groups + add named_group()

## Task 4: Fix Python Named Groups **Wave**: 1 (Critical Bug Fixes) **Category**: unspecified-high **Parent**: Epic #37 ### Problem Python sub() creates empty HashMap for named groups (line 93), so \g{name} in replacements doesn't work. PyMatch also missing named_group() method. ### What to do - RED: Write failing Python tests for sub() with named backrefs and named_group() method - GREEN: Fix ogex-python/src/lib.rs line 93 to pass actual named groups, add named_group() method to PyMatch - REFACTOR: Clean up Python bindings ### Acceptance Criteria - [ ] `ogex.sub(r"(name:abc)", r"[\g{name}]", "abc")` returns "[abc]` - [ ] `match.named_group("name")` returns captured group text ### Files - `ogex-python/src/lib.rs:93` — empty HashMap for named groups - `ogex-python/src/lib.rs:110-183` — PyMatch class ### Commit `fix: Python sub() named groups + add named_group()`
Sign in to join this conversation.
No description provided.