Populate captures also for zero-width matches
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Instead of just using {"captures":[]}. sub functions are use captures for replacement expressions. If we don't populate, captures for empty matches, the replacement expression is run with an empty object as input instead of an object containing the named captures with "" as value: * before: $ jq -n '"123foo456bar" | gsub("[^a-z]*(?<x>[a-z]*)"; "Z\(.x)")' "ZfooZbarZnull" * after: $ jq -n '"123foo456bar" | gsub("[^a-z]*(?<x>[a-z]*)"; "Z\(.x)")' "ZfooZbarZ" --- I also removed a redundant result = NULL; if (result) { ... }
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+16 added−4 removed
- tests:+5 added−1 removed
- other:+11 added−3 removed