Fix docs YAML (introduced in #432)
This commit is contained in:
1 parent
a696c6b551
commit
eb12f0358e
1 file changed
+54
-63
@@ -712,7 +712,7 @@ sections:
|
|||||||
output: ['[5,3,7]']
|
output: ['[5,3,7]']
|
||||||
- program: '.[] | select(.id == "second")'
|
- program: '.[] | select(.id == "second")'
|
||||||
input: '[{"id": "first", "val": 1}, {"id": "second", "val": 2}]'
|
input: '[{"id": "first", "val": 1}, {"id": "second", "val": 2}]'
|
||||||
output: '{"id": "second", "val": 2}'
|
output: ['{"id": "second", "val": 2}']
|
||||||
|
|
||||||
|
|
||||||
- title: "`arrays`, `objects`, `iterables`, `booleans`, `numbers`, `strings`, `nulls`, `values`, `scalars`"
|
- title: "`arrays`, `objects`, `iterables`, `booleans`, `numbers`, `strings`, `nulls`, `values`, `scalars`"
|
||||||
@@ -1720,91 +1720,82 @@ sections:
|
|||||||
examples:
|
examples:
|
||||||
- program: 'capture("(?<a>[a-z]+)-(?<n>[0-9]+)")'
|
- program: 'capture("(?<a>[a-z]+)-(?<n>[0-9]+)")'
|
||||||
input: '"xyzzy-14"'
|
input: '"xyzzy-14"'
|
||||||
output: '{ "a": "xyzzy", "n": "14" }''
|
output: ['{ "a": "xyzzy", "n": "14" }']
|
||||||
|
|
||||||
- title: "`scan(regex)`, `scan(regex; flags)`"
|
- title: "`scan(regex)`, `scan(regex; flags)`"
|
||||||
body: |
|
body: |
|
||||||
|
|
||||||
Emit a stream of the non-overlapping substrings of the input
|
Emit a stream of the non-overlapping substrings of the input
|
||||||
that match the regex in accordance with the flags, if any
|
that match the regex in accordance with the flags, if any
|
||||||
have been specified. If there is no match, the stream is empty.
|
have been specified. If there is no match, the stream is empty.
|
||||||
To capture all the matches for each input string, use the idiom
|
To capture all the matches for each input string, use the idiom
|
||||||
[ expr ], e.g. [ scan(regex) ].
|
`[ expr ]`, e.g. `[ scan(regex) ]`.
|
||||||
|
|
||||||
example:
|
example:
|
||||||
- program: 'scan("c")'
|
- program: 'scan("c")'
|
||||||
input: '"abcdefabc"'
|
input: '"abcdefabc"'
|
||||||
output: '"c"'
|
output: ['"c"', '"c"']
|
||||||
'"c"'
|
|
||||||
|
|
||||||
- program: 'scan("b")'
|
- program: 'scan("b")'
|
||||||
input: ("", "")
|
input: ("", "")
|
||||||
output: '[]'
|
output: ['[]', '[]']
|
||||||
'[]"'
|
|
||||||
|
|
||||||
- title: "`split(regex)`, split(regex; flags)`"
|
- title: "`split(regex)`, `split(regex; flags)`"
|
||||||
body: |
|
body: |
|
||||||
|
|
||||||
For backwards compatibility, `split` emits an array of the strings
|
For backwards compatibility, `split` emits an array of the strings
|
||||||
corresponding to the successive segments of the input string after it
|
corresponding to the successive segments of the input string after it
|
||||||
has been split at the boundaries defined by the regex and any
|
has been split at the boundaries defined by the regex and any
|
||||||
specified flags. The substrings corresponding to the boundaries
|
specified flags. The substrings corresponding to the boundaries
|
||||||
themselves are excluded. If regex is the empty string, then the first
|
themselves are excluded. If regex is the empty string, then the first
|
||||||
match will be the empty string.
|
match will be the empty string.
|
||||||
|
|
||||||
`split(regex)` can be thought of as a wrapper around `splits(regex)`,
|
`split(regex)` can be thought of as a wrapper around `splits(regex)`,
|
||||||
and similarly for `split(regex; flags)`.
|
and similarly for `split(regex; flags)`.
|
||||||
|
|
||||||
example:
|
example:
|
||||||
- program: 'split(", *")'
|
- program: 'split(", *")'
|
||||||
input: '"ab,cd, ef"`
|
input: '"ab,cd, ef"'
|
||||||
output: '["ab","cd","ef"]'
|
output: ['"ab","cd","ef"']
|
||||||
|
|
||||||
|
|
||||||
- title: "`splits(regex)`, splits(regex; flags)`"
|
- title: "`splits(regex)`, splits(regex; flags)`"
|
||||||
body: |
|
body: |
|
||||||
|
|
||||||
These provide the same results as their `split` counterparts,
|
These provide the same results as their `split` counterparts,
|
||||||
but as a stream instead of an array.
|
but as a stream instead of an array.
|
||||||
|
|
||||||
example:
|
example:
|
||||||
- program: 'splits(", *")'
|
- program: 'splits(", *")'
|
||||||
input: '("ab,cd", "ef, gh")`
|
input: '("ab,cd", "ef, gh")'
|
||||||
output:
|
output: ['"ab"', '"cd"', '"ef"', '"gh"']
|
||||||
'"ab"'
|
|
||||||
'"cd"'
|
|
||||||
'"ef"'
|
|
||||||
'"gh"'
|
|
||||||
|
|
||||||
- title: "`sub(regex; tostring)`"
|
- title: "`sub(regex; tostring)`"
|
||||||
|
body: |
|
||||||
|
|
||||||
body: |
|
Emit the string obtained by replacing the first match of regex in the
|
||||||
|
input string with `tostring`, after interpolation. `tostring` should
|
||||||
|
be a jq string, and may contain references to named captures. The
|
||||||
|
named captures are, in effect, presented as a JSON object (as
|
||||||
|
constructed by `capture`) to `tostring`, so a reference to a captured
|
||||||
|
variable named "x" would take the form: "\(.x)".
|
||||||
|
|
||||||
Emit the string obtained by replacing the first match of regex in the
|
example:
|
||||||
input string with `tostring`, after interpolation. `tostring` should
|
- program: 'sub("^[^a-z]*(?<x>[a-z]*).*")'
|
||||||
be a jq string, and may contain references to named captures. The
|
input: '"123abc456"'
|
||||||
named captures are, in effect, presented as a JSON object (as
|
output: '"ZabcZabc"'
|
||||||
constructed by `capture`) to `tostring`, so a reference to a captured
|
|
||||||
variable named "x" would take the form: "\(.x)".
|
|
||||||
|
|
||||||
example:
|
|
||||||
- program: 'sub("^[^a-z]*(?<x>[a-z]*).*")'
|
|
||||||
input: '"123abc456"'
|
|
||||||
output: '"ZabcZabc"'
|
|
||||||
|
|
||||||
|
|
||||||
- title: "`gsub(regex; string)`"
|
- title: "`gsub(regex; string)`"
|
||||||
|
body: |
|
||||||
|
|
||||||
body: |
|
`gsub` is like `sub` but all the non-overlapping occurrences of the regex are
|
||||||
|
replaced by the string, after interpolation.
|
||||||
|
|
||||||
`gsub` is like `sub` but all the non-overlapping occurrences of the regex are
|
example:
|
||||||
replaced by the string, after interpolation.
|
- program: 'gsub("(?<x>.)[^a]*"; "+\(.x)-")'
|
||||||
|
input: '"Abcabc"'
|
||||||
example:
|
output: '"+A-+a-"'
|
||||||
- program: 'gsub("(?<x>.)[^a]*"; "+\(.x)-")'
|
|
||||||
|
|
||||||
input: '"Abcabc"'
|
|
||||||
output: '"+A-+a-"'
|
|
||||||
|
|
||||||
|
|
||||||
- title: Advanced features
|
- title: Advanced features
|
||||||
|
|||||||
Reference in new issue
Block a user