Skip to content

Commit 3ab0363

Browse files
committed
update docs for new RE2 mode features
1 parent 9889958 commit 3ab0363

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ The __last__ capture is embedded in each group, so `g.String()` will return the
4343
| Category | regexp | regexp2 |
4444
| --- | --- | --- |
4545
| Catastrophic backtracking possible | no, constant execution time guarantees | yes, if your pattern is at risk you can use the `re.MatchTimeout` field |
46-
| Python-style capture groups `(?P<name>re)` | yes | no |
46+
| Python-style capture groups `(?P<name>re)` | yes | no (yes in RE2 compat mode) |
4747
| .NET-style capture groups `(?<name>re)` or `(?'name're)` | no | yes |
4848
| comments `(?#comment)` | no | yes |
4949
| branch numbering reset `(?\|a\|b)` | no | no |
@@ -54,14 +54,15 @@ The __last__ capture is embedded in each group, so `g.String()` will return the
5454
| negative lookbehind `(?<!re)` | no | yes |
5555
| back reference `\1` | no | yes |
5656
| named back reference `\k'name'` | no | yes |
57-
| named ascii character class `[[:foo:]]`| yes | no |
57+
| named ascii character class `[[:foo:]]`| yes | no (yes in RE2 compat mode) |
5858
| conditionals `(?(expr)yes\|no)` | no | yes |
5959

6060
## RE2 compatibility mode
6161
The default behavior of `regexp2` is to match the .NET regexp engine, however the `RE2` option is provided to change the parsing to increase compatibility with RE2. Using the `RE2` option when compiling a regexp will not take away any features, but will change the following behaviors:
6262
* add support for named ascii character classes (e.g. `[[:foo:]]`)
6363
* add support for python-style capture groups (e.g. `(P<name>re)`)
64-
64+
* change singleline behavior for `$` to only match end of string (like RE2) (see [#24](https://github.com/dlclark/regexp2/issues/24))
65+
6566
```go
6667
re := regexp2.MustCompile(`Your RE2-compatible pattern`, regexp2.RE2)
6768
if isMatch, _ := re.MatchString(`Something to match`); isMatch {

0 commit comments

Comments
 (0)