diff options
author | William Langford <wlangfor@gmail.com> | 2014-11-12 20:46:34 -0500 |
---|---|---|
committer | William Langford <wlangfor@gmail.com> | 2014-11-12 20:46:34 -0500 |
commit | 30e00820a7cd6a198bc24a0499ee5c3ceb38ae75 (patch) | |
tree | 75014a4c95ea89f05a45e55d047162f03a932d07 | |
parent | 89791a000ba8fd614d8a8fa59a5ba76f21ea4d1d (diff) |
Fix #600. Add regression test
-rw-r--r-- | builtin.c | 4 | ||||
-rw-r--r-- | tests/all.test | 4 |
2 files changed, 5 insertions, 3 deletions
@@ -1057,9 +1057,7 @@ static const char* const jq_builtins[] = { // # create the \"capture\" object: " | reduce ( $r | .captures | .[] | select(.name != null) | { (.name) : .string } ) as $pair" " ({}; . + $pair)" - " | if . == {} then $in | .[0:$r.offset]+s+.[$r.offset+$r.length:]" - " else (. | s)" - " end" + " | $in[0:$r.offset] + s + $in[$r.offset+$r.length:]" " end ;", // // repeated substitution of re (which may contain named captures) diff --git a/tests/all.test b/tests/all.test index 84d4491d..c4c3b0df 100644 --- a/tests/all.test +++ b/tests/all.test @@ -859,6 +859,10 @@ capture("(?<a>[a-z]+)-(?<n>[0-9]+)") ["a,b, c, d, e,f", ", a,b, c, d, e,f, "] ["a,b:c, d, e,f",":a,b, c, d, e,f, "] +sub("^(?<head>.)"; "Head=\(.head) Tail=") +"abcdef" +"Head=a Tail=bcdef" + [.[] | gsub(", "; ":")] ["a,b, c, d, e,f",", a,b, c, d, e,f, "] ["a,b:c:d:e,f",":a,b:c:d:e,f:"] |