Skip to content

Conversation

@joente
Copy link
Member

@joente joente commented May 27, 2025

Description

It would be useful to have an option to get match groups using a regular expression.

Example:

m = /version ((\d+\.?)+)/.match("This is version 3.5.1 of the program.");
m; 

Response:

[
    "version 3.5.1",
    "3.5.1",
    "1"
]

It returns an array where the first element is the full capture, followed by the capture groups.
It should return nil if no match is found.

If the regular expresstion has the g (global) flag, then an array will be returned with all matches, an empty list if no matches are found.

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

  • Test collection function

Test Configuration:
If applicable, add your test configuration.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • New and existing unit tests pass locally with my changes

@joente joente merged commit a29a249 into main May 28, 2025
1 check passed
@joente joente deleted the mtch branch May 28, 2025 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants