Skip to content

Improved support for regex capture group names#5960

Open
Baaaaaz wants to merge 2 commits intoRPTools:developfrom
Baaaaaz:feature/5959-strFind-named-capture-groups
Open

Improved support for regex capture group names#5960
Baaaaaz wants to merge 2 commits intoRPTools:developfrom
Baaaaaz:feature/5959-strFind-named-capture-groups

Conversation

@Baaaaaz
Copy link
Copy Markdown
Contributor

@Baaaaaz Baaaaaz commented May 4, 2026

closes #5959

Description of the Change

  • Changed stringFind() method:
    • named capture groups present in the regex pattern are now stored as a variable
    • group matches are also now stored as variables using the related group name (meaning existing getGroup...() functions also now work with capture group names passed to strFind()).
    • slight refactoring for clarity and to reduce repetition in string concatenation.
  • New getGroupNames() MTScript function:
    • args: id
    • returns a JSON object of mapping named capture groups present in the regex pattern to their group indexes
  • New json.fromStrFind() MTScript function:
    • args: string, pattern [, returnNamedGroups (default = false) [, returnGroup0 (default = false)]]
    • matches the pattern against the input string and returns a Json array of objects with capture groups as keys and matches as values

Possible Drawbacks

For stringFind() if capture group names are used in the regex, stored matches are duplicated in variables referenced by either index or by name.

Documentation Notes

t.b.c.

Release Notes

Improved support for regex capture group names


This change is Reviewable

@github-actions github-actions Bot added the feature Adding functionality that adds value label May 4, 2026
@Baaaaaz Baaaaaz changed the title Feature/5959 str find named capture groups Improved support for regex capture group names May 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Adding functionality that adds value

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Enhance strFind()s related getGroup...() functions to support regex named capture groups.

1 participant