Skip to content

Commit 7eac9ce

Browse files
committed
Update PCRE -> PCRE2
This reflects the migration we made for user-facing regex in semgrep/semgrep#9919
1 parent 7880800 commit 7eac9ce

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

docs/writing-rules/rule-syntax.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ The below optional fields must reside underneath a `patterns` field.
5252
| [`metavariable-comparison`](#metavariable-comparison) | `map` | Compare metavariables against basic [Python expressions](https://docs.python.org/3/reference/expressions.html#comparisons) |
5353
| [`pattern-not`](#pattern-not) | `string` | Logical NOT - remove findings matching this expression |
5454
| [`pattern-not-inside`](#pattern-not-inside) | `string` | Keep findings that do not lie inside this pattern |
55-
| [`pattern-not-regex`](#pattern-not-regex) | `string` | Filter results using a [PCRE](https://www.pcre.org/original/doc/html/pcrepattern.html)-compatible pattern in multiline mode |
55+
| [`pattern-not-regex`](#pattern-not-regex) | `string` | Filter results using a [PCRE2](https://www.pcre.org/current/doc/html/pcre2pattern.html)-compatible pattern in multiline mode |
5656

5757
## Operators
5858

@@ -152,10 +152,10 @@ This rule looks for usage of the Python standard library functions `hashlib.md5`
152152

153153
### `pattern-regex`
154154

155-
The `pattern-regex` operator searches files for substrings matching the given [PCRE](https://www.pcre.org/original/doc/html/pcrepattern.html) pattern. This is useful for migrating existing regular expression code search functionality to Semgrep. Perl-Compatible Regular Expressions (PCRE) is a full-featured regex library that is widely compatible with Perl, but also with the respective regex libraries of Python, JavaScript, Go, Ruby, and Java. Patterns are compiled in multiline mode, for example `^` and `$` matches at the beginning and end of lines respectively in addition to the beginning and end of input.
155+
The `pattern-regex` operator searches files for substrings matching the given [PCRE2](https://www.pcre.org/current/doc/html/pcre2pattern.html) pattern. This is useful for migrating existing regular expression code search functionality to Semgrep. Perl-Compatible Regular Expressions (PCRE) is a full-featured regex library that is widely compatible with Perl, but also with the respective regex libraries of Python, JavaScript, Go, Ruby, and Java. Patterns are compiled in multiline mode, for example `^` and `$` matches at the beginning and end of lines respectively in addition to the beginning and end of input.
156156

157157
:::caution
158-
PCRE supports only a [limited number of Unicode character properties](https://www.pcre.org/original/doc/html/pcrepattern.html#uniextseq). For example, `\p{Egyptian_Hieroglyphs}` is supported but `\p{Bidi_Control}` isn't.
158+
PCRE2 supports only a [limited number of Unicode character properties](https://www.pcre.org/current/doc/html/pcre2pattern.html#uniextseq). For example, `\p{Egyptian_Hieroglyphs}` is supported but `\p{Bidi_Control}` isn't.
159159
:::
160160

161161
#### Example: `pattern-regex` combined with other pattern operators
@@ -229,7 +229,7 @@ acbd
229229

230230
### `pattern-not-regex`
231231

232-
The `pattern-not-regex` operator filters results using a [PCRE](https://www.pcre.org/original/doc/html/pcrepattern.html) regular expression in multiline mode. This is most useful when combined with regular-expression only rules, providing an easy way to filter findings without having to use negative lookaheads. `pattern-not-regex` works with regular `pattern` clauses, too.
232+
The `pattern-not-regex` operator filters results using a [PCRE2](https://www.pcre.org/current/doc/html/pcre2pattern.html) regular expression in multiline mode. This is most useful when combined with regular-expression only rules, providing an easy way to filter findings without having to use negative lookaheads. `pattern-not-regex` works with regular `pattern` clauses, too.
233233

234234
The syntax for this operator is the same as `pattern-regex`.
235235

@@ -373,7 +373,7 @@ To make a list of multiple focus metavariables using set union semantics that ma
373373

374374
### `metavariable-regex`
375375

376-
The `metavariable-regex` operator searches metavariables for a [PCRE](https://www.pcre.org/original/doc/html/pcrepattern.html) regular expression. This is useful for filtering results based on a [metavariable’s](pattern-syntax.mdx#metavariables) value. It requires the `metavariable` and `regex` keys and can be combined with other pattern operators.
376+
The `metavariable-regex` operator searches metavariables for a [PCRE2](https://www.pcre.org/current/doc/html/pcre2pattern.html) regular expression. This is useful for filtering results based on a [metavariable’s](pattern-syntax.mdx#metavariables) value. It requires the `metavariable` and `regex` keys and can be combined with other pattern operators.
377377

378378
```yaml
379379
rules:

src/components/reference/_required-rule-fields.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ All required fields must be present at the top-level of a rule, immediately unde
99
| [`pattern`](#pattern)_\*_ | `string` | Find code matching this expression |
1010
| [`patterns`](#patterns)_\*_ | `array` | Logical AND of multiple patterns |
1111
| [`pattern-either`](#pattern-either)_\*_ | `array` | Logical OR of multiple patterns |
12-
| [`pattern-regex`](#pattern-regex)_\*_ | `string` | Find code matching this [PCRE](https://www.pcre.org/original/doc/html/pcrepattern.html)-compatible pattern in multiline mode |
12+
| [`pattern-regex`](#pattern-regex)_\*_ | `string` | Find code matching this [PCRE2](https://www.pcre.org/current/doc/html/pcre2pattern.html)-compatible pattern in multiline mode |
1313

1414
:::info
1515
Only one of the following is required: `pattern`, `patterns`, `pattern-either`, `pattern-regex`

0 commit comments

Comments
 (0)