1
0
mirror of https://github.com/golang/go synced 2024-09-29 09:14:29 -06:00
This commit is contained in:
Mauri de Souza Meneguzzo 2024-02-18 09:17:33 -03:00
parent 5191d18236
commit 0f8c8df4f2

View File

@ -14,8 +14,8 @@ facilities of package [regexp] (such as [regexp.Compile] and [regexp.Match]) ins
The regular expression syntax understood by this package when parsing with the [Perl] flag is as follows.
Parts of the syntax can be disabled by passing alternate flags to [Parse].
Single characters:
. any character, possibly including newline (flag s=true)
[xyz] character class
[^xyz] negated character class
@ -29,10 +29,12 @@ Single characters:
\P{Greek} negated Unicode character class
Composites:
xy x followed by y
x|y x or y (prefer x)
Repetitions:
x* zero or more x, prefer more
x+ one or more x, prefer more
x? zero or one x, prefer one
@ -51,6 +53,7 @@ reject forms that create a minimum or maximum repetition count above 1000.
Unlimited repetitions are not subject to this restriction.
Grouping:
(re) numbered capturing group (submatch)
(?P<name>re) named & numbered capturing group (submatch)
(?<name>re) named & numbered capturing group (submatch)
@ -66,6 +69,7 @@ Grouping:
U ungreedy: swap meaning of x* and x*?, x+ and x+?, etc (default false)
Empty strings:
^ at beginning of text or line (flag m=true)
$ at end of text (like \z not \Z) or line (flag m=true)
\A at beginning of text
@ -74,6 +78,7 @@ Empty strings:
\z at end of text
Escape sequences:
\a bell (== \007)
\f form feed (== \014)
\t horizontal tab (== \011)
@ -87,6 +92,7 @@ Escape sequences:
\Q...\E literal text ... even if ... has punctuation
Character class elements:
x single character
A-Z character range (inclusive)
\d Perl character class
@ -95,6 +101,7 @@ Character class elements:
\pF Unicode character class F (one-letter name)
Named character classes as character class elements:
[\d] digits (== \d)
[^\d] not digits (== \D)
[\D] not digits (== \D)
@ -105,6 +112,7 @@ Named character classes as character class elements:
[^\p{Name}] named Unicode property inside negated character class (== \P{Name})
Perl character classes (all ASCII-only):
\d digits (== [0-9])
\D not digits (== [^0-9])
\s whitespace (== [\t\n\f\r ])
@ -113,6 +121,7 @@ Perl character classes (all ASCII-only):
\W not word characters (== [^0-9A-Za-z_])
ASCII character classes:
[[:alnum:]] alphanumeric (== [0-9A-Za-z])
[[:alpha:]] alphabetic (== [A-Za-z])
[[:ascii:]] ASCII (== [\x00-\x7F])