diff options
author | Nicolas Williams <nico@cryptonector.com> | 2014-10-03 17:52:11 -0500 |
---|---|---|
committer | Nicolas Williams <nico@cryptonector.com> | 2014-10-03 17:58:45 -0500 |
commit | 1796a716eaebb12caa0cb3441a1e50a180f5f754 (patch) | |
tree | 30123a387481503306d7eecf6fcc9971a19c4f19 | |
parent | 07d8d5c5ef08b942b4cd0f8b9d1af6beb870841f (diff) |
Restore `split/1`; don't use regexp (fix #576)
-rw-r--r-- | builtin.c | 1 | ||||
-rw-r--r-- | docs/content/3.manual/manual.yml | 7 | ||||
-rw-r--r-- | tests/all.test | 10 |
3 files changed, 7 insertions, 11 deletions
@@ -1046,7 +1046,6 @@ static const char* const jq_builtins[] = { // // split emits an array for backward compatibility "def split($re; flags): [ splits($re; flags) ];", - "def split($re): [ splits($re; null) ];", // // If s contains capture variables, then create a capture object and pipe it to s "def sub($re; s):" diff --git a/docs/content/3.manual/manual.yml b/docs/content/3.manual/manual.yml index a6dfd81d..16bee1eb 100644 --- a/docs/content/3.manual/manual.yml +++ b/docs/content/3.manual/manual.yml @@ -1736,7 +1736,7 @@ sections: input: ("", "") output: ['[]', '[]'] - - title: "`split(regex)`, `split(regex; flags)`" + - title: "`split(regex; flags)`" body: | For backwards compatibility, `split` emits an array of the strings @@ -1746,11 +1746,8 @@ sections: themselves are excluded. If regex is the empty string, then the first match will be the empty string. - `split(regex)` can be thought of as a wrapper around `splits(regex)`, - and similarly for `split(regex; flags)`. - example: - - program: 'split(", *")' + - program: 'split(", *"; null)' input: '"ab,cd, ef"' output: ['"ab","cd","ef"'] diff --git a/tests/all.test b/tests/all.test index d1cdc2ca..18078909 100644 --- a/tests/all.test +++ b/tests/all.test @@ -869,16 +869,16 @@ capture("(?<a>[a-z]+)-(?<n>[0-9]+)") [.[] | split(", ")] ["a,b, c, d, e,f",", a,b, c, d, e,f, "] -[["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(", *";":")], [gsub(", *";":")], [scan(", *")], split(", *")]] +[.[]|[[sub(", *";":")], [gsub(", *";":")], [scan(", *")]]] ["a,b, c, d, e,f",", a,b, c, d, e,f, "] -[[["a:b, c, d, e,f"],["a:b:c:d:e:f"],[",",", ",", ",", ",","],["a","b","c","d","e","f"]],[[":a,b, c, d, e,f, "],[":a:b:c:d:e:f:"],[", ",",",", ",", ",", ",",",", "],["","a","b","c","d","e","f",""]]] +[[["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(", +";":")], [gsub(", +";":")], [scan(", +")], split(", +")]] +[.[]|[[sub(", +";":")], [gsub(", +";":")], [scan(", +")]]] ["a,b, c, d, e,f",", a,b, c, d, e,f, "] -[[["a,b:c, d, e,f"],["a,b:c:d:e,f"],[", ",", ",", "],["a,b","c","d","e,f"]],[[":a,b, c, d, e,f, "],[":a,b:c:d:e,f:"],[", ",", ",", ",", ",", "],["","a,b","c","d","e,f",""]]] +[[["a,b:c, d, e,f"],["a,b:c:d:e,f"],[", ",", ",", "]],[[":a,b, c, d, e,f, "],[":a,b:c:d:e,f:"],[", ",", ",", ",", ",", "]]] # reference to named captures gsub("(?<x>.)[^a]*"; "+\(.x)-") |