mirror of
https://github.com/stedolan/jq.git
synced 2024-05-11 05:55:39 +00:00
45 lines
1.2 KiB
Plaintext
45 lines
1.2 KiB
Plaintext
![]() |
split(", ")
|
||
|
"a, b,c,d, e, "
|
||
|
["a","b,c,d","e",""]
|
||
|
|
||
|
walk( if type == "object" then with_entries( .key |= sub( "^_+"; "") ) else . end )
|
||
|
[ { "_a": { "__b": 2 } } ]
|
||
|
[{"a":{"b":2}}]
|
||
|
|
||
|
test("foo")
|
||
|
"foo"
|
||
|
true
|
||
|
|
||
|
.[] | test("a b c # spaces are ignored"; "ix")
|
||
|
["xabcd", "ABC"]
|
||
|
true
|
||
|
true
|
||
|
|
||
|
match("(abc)+"; "g")
|
||
|
"abc abc"
|
||
|
{"offset": 0, "length": 3, "string": "abc", "captures": [{"offset": 0, "length": 3, "string": "abc", "name": null}]}
|
||
|
{"offset": 4, "length": 3, "string": "abc", "captures": [{"offset": 4, "length": 3, "string": "abc", "name": null}]}
|
||
|
|
||
|
match("foo")
|
||
|
"foo bar foo"
|
||
|
{"offset": 0, "length": 3, "string": "foo", "captures": []}
|
||
|
|
||
|
match(["foo", "ig"])
|
||
|
"foo bar FOO"
|
||
|
{"offset": 0, "length": 3, "string": "foo", "captures": []}
|
||
|
{"offset": 8, "length": 3, "string": "FOO", "captures": []}
|
||
|
|
||
|
match("foo (?<bar123>bar)? foo"; "ig")
|
||
|
"foo bar foo foo foo"
|
||
|
{"offset": 0, "length": 11, "string": "foo bar foo", "captures": [{"offset": 4, "length": 3, "string": "bar", "name": "bar123"}]}
|
||
|
{"offset": 12, "length": 8, "string": "foo foo", "captures": [{"offset": -1, "length": 0, "string": null, "name": "bar123"}]}
|
||
|
|
||
|
[ match("."; "g")] | length
|
||
|
"abc"
|
||
|
3
|
||
|
|
||
|
capture("(?<a>[a-z]+)-(?<n>[0-9]+)")
|
||
|
"xyzzy-14"
|
||
|
{ "a": "xyzzy", "n": "14" }
|
||
|
|