Skip to content

Commit

Permalink
Fix #600. Add regression test
Browse files Browse the repository at this point in the history
  • Loading branch information
wtlangford committed Nov 13, 2014
1 parent 89791a0 commit 30e0082
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 1 addition & 3 deletions builtin.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions tests/all.test
Original file line number Diff line number Diff line change
Expand Up @@ -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:"]
Expand Down

0 comments on commit 30e0082

Please sign in to comment.