Commit 1b3c969a authored by Rob Pike's avatar Rob Pike

regexp: identify that submatch is also known as capturing group

Mention the syntax is defined by the regexp/syntax package.
Fixes #3953.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/7702044
parent 916f4cfa
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
// general syntax used by Perl, Python, and other languages. // general syntax used by Perl, Python, and other languages.
// More precisely, it is the syntax accepted by RE2 and described at // More precisely, it is the syntax accepted by RE2 and described at
// http://code.google.com/p/re2/wiki/Syntax, except for \C. // http://code.google.com/p/re2/wiki/Syntax, except for \C.
// For an overview of the syntax, run
// godoc regexp/syntax
// //
// All characters are UTF-8-encoded code points. // All characters are UTF-8-encoded code points.
// //
...@@ -27,11 +29,11 @@ ...@@ -27,11 +29,11 @@
// of bytes; return values are adjusted as appropriate. // of bytes; return values are adjusted as appropriate.
// //
// If 'Submatch' is present, the return value is a slice identifying the // If 'Submatch' is present, the return value is a slice identifying the
// successive submatches of the expression. Submatches are matches of // successive submatches of the expression. Submatches are matches of
// parenthesized subexpressions within the regular expression, numbered from // parenthesized subexpressions (also known as capturing groups) within the
// left to right in order of opening parenthesis. Submatch 0 is the match of // regular expression, numbered from left to right in order of opening
// the entire expression, submatch 1 the match of the first parenthesized // parenthesis. Submatch 0 is the match of the entire expression, submatch 1
// subexpression, and so on. // the match of the first parenthesized subexpression, and so on.
// //
// If 'Index' is present, matches and submatches are identified by byte index // If 'Index' is present, matches and submatches are identified by byte index
// pairs within the input string: result[2*n:2*n+1] identifies the indexes of // pairs within the input string: result[2*n:2*n+1] identifies the indexes of
......
...@@ -47,9 +47,9 @@ Repetitions: ...@@ -47,9 +47,9 @@ Repetitions:
x{n}? exactly n x x{n}? exactly n x
Grouping: Grouping:
(re) numbered capturing group (re) numbered capturing group (submatch)
(?P<name>re) named & numbered capturing group (?P<name>re) named & numbered capturing group (submatch)
(?:re) non-capturing group (?:re) non-capturing group (submatch)
(?flags) set flags within current group; non-capturing (?flags) set flags within current group; non-capturing
(?flags:re) set flags during re; non-capturing (?flags:re) set flags during re; non-capturing
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment