Fix #600. Add regression test

This commit is contained in:
William Langford committed 2014-11-12 20:46:34 -05:00
1 parent 89791a000b
commit 30e00820a7
2 files changed
+5 -3

No files matched your search

+1 -3
View File
@@ -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)
+4
View File
@@ -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:"]