✨ feat(mq-lang): add capture builtin function for regex named group extraction#1272
Merged
✨ feat(mq-lang): add capture builtin function for regex named group extraction#1272
Conversation
…xtraction Add capture builtin that extracts named regex groups into a dict. Fix dict key to use group name instead of matched text, and add integration tests covering named groups, no-match, single group, and markdown node inputs.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a new capture builtin function to the mq-lang crate for extracting named regex groups into a dictionary. The implementation follows the existing patterns for regex-based builtin functions in the codebase, including proper regex caching and error handling.
Changes:
- Added
capturebuiltin function that extracts named capture groups from regex patterns into a dictionary - Implemented proper handling for strings, markdown nodes, and None values
- Added comprehensive integration tests covering named groups, no-match scenarios, single groups, and markdown node inputs
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| crates/mq-lang/src/eval/builtin.rs | Implemented the CAPTURE builtin, capture_re and _capture_re helper functions, added function registration and documentation |
| crates/mq-run/tests/integration_tests.rs | Added 4 integration test cases covering various capture scenarios including named groups, no matches, single groups, and markdown nodes |
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add capture builtin that extracts named regex groups into a dict. Fix dict key to use group name instead of matched text, and add integration tests covering named groups, no-match, single group, and markdown node inputs.