fix(strings): ignore unnamed capture groups - #2770
Open
maximilize wants to merge 1 commit into
Open
Conversation
capture() built a map key from SubexpNames() for every submatch; unnamed groups (name "") became an empty-string key (and duplicate keys for several). jq returns only named captures.
cymertek
added a commit
to cymertek/yq
that referenced
this pull request
Jul 29, 2026
…hensive documentation ## Critical Bug Fixes (mikefarah#2786, mikefarah#2785, mikefarah#2769, mikefarah#2770, mikefarah#2771, mikefarah#2772) - Fixed missing keys in read-only context operations - Added negative array index support to `has()` function - Enhanced TOML comment roundtripping during decode/encode cycles - Added capture group support for XML/HTML regex parsing - Fixed integer overflow in sort operations - Corrected first operation returning key instead of value ## New Features - Added `--stdin-filename` flag for virtual filename context - Preserved large integers beyond JavaScript Number.MAX_SAFE_INTEGER in JSON output ## Crash & Memory Leak Fixes - **File handle leaks**: Added proper cleanup to operator_load.go, stream_evaluator.go, front_matter.go, printer_writer.go (MultiPrintWriter) - **Bounds checking**: Fixed index out of bounds in candidate_node.go FilterMapContentByKey and decoder_xml.go Content[0] access - **Panic prevention**: Enhanced TOML decoder recover() to always convert panics to errors, added EOF error logging ## Go Documentation & Conventions - Added GoDoc comments to 200+ exported symbols across all packages (golint: 0 warnings) - Removed all redundant `//nolint:golint` directives - proper documentation instead of suppression flags - Standardized naming conventions: URI, JSON, XML, LHS/RHS throughout codebase
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.
what
captureemits unnamed regex groups as a map entry with an empty-string key, and produces duplicate empty keys when there are several:Two unnamed groups (
capture("(a)(b)")onab) yield a mapping with two identical""keys.why
capture(pkg/yqlib/operator_strings.go) iterates over every submatch and unconditionally builds a key fromregEx.SubexpNames(), which is""for unnamed groups. jq only returns named capture groups, andstring-operators.mddocuments capture as returning "named RegEx capture groups in a map".fix
Skip submatches whose name is empty, matching jq. Regression scenario added (
skipDoc).