mirror of
https://github.com/stedolan/jq.git
synced 2024-05-11 05:55:39 +00:00
This commit is contained in:
@@ -2293,48 +2293,48 @@ sections:
|
||||
output: ['[null, 1]']
|
||||
|
||||
|
||||
- title: Regular expressions (PCRE)
|
||||
- title: Regular expressions
|
||||
body: |
|
||||
|
||||
jq uses the
|
||||
[Oniguruma regular expression library](https://github.com/kkos/oniguruma/blob/master/doc/RE),
|
||||
as do php, ruby, TextMate, Sublime Text, etc, so the
|
||||
as do PHP, Ruby, TextMate, Sublime Text, etc, so the
|
||||
description here will focus on jq specifics.
|
||||
|
||||
The jq regex filters are defined so that they can be used using
|
||||
one of these patterns:
|
||||
|
||||
STRING | FILTER( REGEX )
|
||||
STRING | FILTER( REGEX; FLAGS )
|
||||
STRING | FILTER( [REGEX] )
|
||||
STRING | FILTER( [REGEX, FLAGS] )
|
||||
STRING | FILTER(REGEX)
|
||||
STRING | FILTER(REGEX; FLAGS)
|
||||
STRING | FILTER([REGEX])
|
||||
STRING | FILTER([REGEX, FLAGS])
|
||||
|
||||
where:
|
||||
|
||||
* STRING, REGEX and FLAGS are jq strings and subject to jq string interpolation;
|
||||
* REGEX, after string interpolation, should be a valid PCRE regex;
|
||||
* STRING, REGEX, and FLAGS are jq strings and subject to jq string interpolation;
|
||||
* REGEX, after string interpolation, should be a valid regular expression;
|
||||
* FILTER is one of `test`, `match`, or `capture`, as described below.
|
||||
|
||||
FLAGS is a string consisting of one of more of the supported flags:
|
||||
|
||||
* `g` - Global search (find all matches, not just the first)
|
||||
* `i` - Case insensitive search
|
||||
* `m` - Multi line mode ('.' will match newlines)
|
||||
* `m` - Multi line mode (`.` will match newlines)
|
||||
* `n` - Ignore empty matches
|
||||
* `p` - Both s and m modes are enabled
|
||||
* `s` - Single line mode ('^' -> '\A', '$' -> '\Z')
|
||||
* `s` - Single line mode (`^` -> `\A`, `$` -> `\Z`)
|
||||
* `l` - Find longest possible matches
|
||||
* `x` - Extended regex format (ignore whitespace and comments)
|
||||
|
||||
To match whitespace in an x pattern use an escape such as \s, e.g.
|
||||
To match a whitespace with the `x` flag, use `\s`, e.g.
|
||||
|
||||
* test( "a\\\\sb"; "x" )
|
||||
jq -n '"a b" | test("a\\sb"; "x")'
|
||||
|
||||
Note that certain flags may also be specified within REGEX, e.g.
|
||||
|
||||
* jq -n '("test", "TEst", "teST", "TEST") | test( "(?i)te(?-i)st" )'
|
||||
jq -n '("test", "TEst", "teST", "TEST") | test("(?i)te(?-i)st")'
|
||||
|
||||
evaluates to: true, true, false, false.
|
||||
evaluates to: `true`, `true`, `false`, `false`.
|
||||
|
||||
entries:
|
||||
- title: "`test(val)`, `test(regex; flags)`"
|
||||
|
@@ -1954,46 +1954,47 @@ sections:
|
||||
output: ['[null, 1]']
|
||||
|
||||
|
||||
- title: Regular expressions (PCRE)
|
||||
- title: Regular expressions
|
||||
body: |
|
||||
|
||||
jq uses the Oniguruma regular expression library, as do php,
|
||||
ruby, TextMate, Sublime Text, etc, so the description here
|
||||
jq uses the Oniguruma regular expression library, as do PHP,
|
||||
Ruby, TextMate, Sublime Text, etc, so the description here
|
||||
will focus on jq specifics.
|
||||
|
||||
The jq regex filters are defined so that they can be used using
|
||||
one of these patterns:
|
||||
|
||||
STRING | FILTER( REGEX )
|
||||
STRING | FILTER( REGEX; FLAGS )
|
||||
STRING | FILTER( [REGEX] )
|
||||
STRING | FILTER( [REGEX, FLAGS] )
|
||||
STRING | FILTER(REGEX)
|
||||
STRING | FILTER(REGEX; FLAGS)
|
||||
STRING | FILTER([REGEX])
|
||||
STRING | FILTER([REGEX, FLAGS])
|
||||
|
||||
where:
|
||||
* STRING, REGEX and FLAGS are jq strings and subject to jq string interpolation;
|
||||
* REGEX, after string interpolation, should be a valid PCRE regex;
|
||||
|
||||
* STRING, REGEX, and FLAGS are jq strings and subject to jq string interpolation;
|
||||
* REGEX, after string interpolation, should be a valid regular expression;
|
||||
* FILTER is one of `test`, `match`, or `capture`, as described below.
|
||||
|
||||
FLAGS is a string consisting of one of more of the supported flags:
|
||||
|
||||
* `g` - Global search (find all matches, not just the first)
|
||||
* `i` - Case insensitive search
|
||||
* `m` - Multi line mode ('.' will match newlines)
|
||||
* `m` - Multi line mode (`.` will match newlines)
|
||||
* `n` - Ignore empty matches
|
||||
* `p` - Both s and m modes are enabled
|
||||
* `s` - Single line mode ('^' -> '\A', '$' -> '\Z')
|
||||
* `s` - Single line mode (`^` -> `\A`, `$` -> `\Z`)
|
||||
* `l` - Find longest possible matches
|
||||
* `x` - Extended regex format (ignore whitespace and comments)
|
||||
|
||||
To match whitespace in an x pattern use an escape such as \s, e.g.
|
||||
To match a whitespace with the `x` flag, use `\s`, e.g.
|
||||
|
||||
* test( "a\\\\sb"; "x" )
|
||||
jq -n '"a b" | test("a\\sb"; "x")'
|
||||
|
||||
Note that certain flags may also be specified within REGEX, e.g.
|
||||
|
||||
* jq -n '("test", "TEst", "teST", "TEST") | test( "(?i)te(?-i)st" )'
|
||||
jq -n '("test", "TEst", "teST", "TEST") | test("(?i)te(?-i)st")'
|
||||
|
||||
evaluates to: true, true, false, false.
|
||||
evaluates to: `true`, `true`, `false`, `false`.
|
||||
|
||||
entries:
|
||||
- title: "`test(val)`, `test(regex; flags)`"
|
||||
|
@@ -2200,46 +2200,47 @@ sections:
|
||||
output: ['[null, 1]']
|
||||
|
||||
|
||||
- title: Regular expressions (PCRE)
|
||||
- title: Regular expressions
|
||||
body: |
|
||||
|
||||
jq uses the Oniguruma regular expression library, as do php,
|
||||
ruby, TextMate, Sublime Text, etc, so the description here
|
||||
jq uses the Oniguruma regular expression library, as do PHP,
|
||||
Ruby, TextMate, Sublime Text, etc, so the description here
|
||||
will focus on jq specifics.
|
||||
|
||||
The jq regex filters are defined so that they can be used using
|
||||
one of these patterns:
|
||||
|
||||
STRING | FILTER( REGEX )
|
||||
STRING | FILTER( REGEX; FLAGS )
|
||||
STRING | FILTER( [REGEX] )
|
||||
STRING | FILTER( [REGEX, FLAGS] )
|
||||
STRING | FILTER(REGEX)
|
||||
STRING | FILTER(REGEX; FLAGS)
|
||||
STRING | FILTER([REGEX])
|
||||
STRING | FILTER([REGEX, FLAGS])
|
||||
|
||||
where:
|
||||
* STRING, REGEX and FLAGS are jq strings and subject to jq string interpolation;
|
||||
* REGEX, after string interpolation, should be a valid PCRE regex;
|
||||
|
||||
* STRING, REGEX, and FLAGS are jq strings and subject to jq string interpolation;
|
||||
* REGEX, after string interpolation, should be a valid regular expression;
|
||||
* FILTER is one of `test`, `match`, or `capture`, as described below.
|
||||
|
||||
FLAGS is a string consisting of one of more of the supported flags:
|
||||
|
||||
* `g` - Global search (find all matches, not just the first)
|
||||
* `i` - Case insensitive search
|
||||
* `m` - Multi line mode ('.' will match newlines)
|
||||
* `m` - Multi line mode (`.` will match newlines)
|
||||
* `n` - Ignore empty matches
|
||||
* `p` - Both s and m modes are enabled
|
||||
* `s` - Single line mode ('^' -> '\A', '$' -> '\Z')
|
||||
* `s` - Single line mode (`^` -> `\A`, `$` -> `\Z`)
|
||||
* `l` - Find longest possible matches
|
||||
* `x` - Extended regex format (ignore whitespace and comments)
|
||||
|
||||
To match whitespace in an x pattern use an escape such as \s, e.g.
|
||||
To match a whitespace with the `x` flag, use `\s`, e.g.
|
||||
|
||||
* test( "a\\\\sb"; "x" )
|
||||
jq -n '"a b" | test("a\\sb"; "x")'
|
||||
|
||||
Note that certain flags may also be specified within REGEX, e.g.
|
||||
|
||||
* jq -n '("test", "TEst", "teST", "TEST") | test( "(?i)te(?-i)st" )'
|
||||
jq -n '("test", "TEst", "teST", "TEST") | test("(?i)te(?-i)st")'
|
||||
|
||||
evaluates to: true, true, false, false.
|
||||
evaluates to: `true`, `true`, `false`, `false`.
|
||||
|
||||
entries:
|
||||
- title: "`test(val)`, `test(regex; flags)`"
|
||||
|
Reference in New Issue
Block a user