1
0
mirror of https://github.com/stedolan/jq.git synced 2024-05-11 05:55:39 +00:00

Test starts/endswith and string multiplication

This commit is contained in:
Nicolas Williams
2013-11-29 15:51:51 -06:00
parent 5989dbdfcf
commit 63bed9bdf1

View File

@@ -574,6 +574,19 @@ def inc(x): x |= .+1; inc(.[].a)
{}
[true, true, false]
# string operations
[.[]|startswith("foo")]
["fo", "foo", "barfoo", "foobar", "barfoob"]
[false, true, false, true, false]
[.[]|endswith("foo")]
["fo", "foo", "barfoo", "foobar", "barfoob"]
[false, true, true, false, false]
[.[] * 3]
["a", "ab", "abc"]
["aaa", "ababab", "abcabcabc"]
map(.[1] as $needle | .[0] | contains($needle))
[[[],[]], [[1,2,3], [1,2]], [[1,2,3], [3,1]], [[1,2,3], [4]], [[1,2,3], [1,4]]]
[true, true, true, false, false]