]> Cypherpunks repositories - gostls13.git/commitdiff
regexp: identify that submatch is also known as capturing group
authorRob Pike <r@golang.org>
Mon, 11 Mar 2013 23:23:06 +0000 (16:23 -0700)
committerRob Pike <r@golang.org>
Mon, 11 Mar 2013 23:23:06 +0000 (16:23 -0700)
Mention the syntax is defined by the regexp/syntax package.
Fixes #3953.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/7702044

src/pkg/regexp/regexp.go
src/pkg/regexp/syntax/doc.go

index 3aa16dec60672359810e2c25e3640a5c0714d6b5..6f6908a74ff14d9fb73ebba9e5eadd757221357f 100644 (file)
@@ -8,6 +8,8 @@
 // general syntax used by Perl, Python, and other languages.
 // More precisely, it is the syntax accepted by RE2 and described at
 // 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.
 //
 // of bytes; return values are adjusted as appropriate.
 //
 // If 'Submatch' is present, the return value is a slice identifying the
-// successive submatches of the expression.  Submatches are matches of
-// parenthesized subexpressions within the regular expression, numbered from
-// left to right in order of opening parenthesis.  Submatch 0 is the match of
-// the entire expression, submatch 1 the match of the first parenthesized
-// subexpression, and so on.
+// successive submatches of the expression. Submatches are matches of
+// parenthesized subexpressions (also known as capturing groups) within the
+// regular expression, numbered from left to right in order of opening
+// parenthesis. Submatch 0 is the match of the entire expression, submatch 1
+// the match of the first parenthesized subexpression, and so on.
 //
 // 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
index 843a6f6a4242ec7a6f1c95c508717fea30abe9e8..bcb5d051bc9523c5ae32978382bc44b39e760a79 100644 (file)
@@ -47,9 +47,9 @@ Repetitions:
   x{n}?          exactly n x
 
 Grouping:
-  (re)           numbered capturing group
-  (?P<name>re)   named & numbered capturing group
-  (?:re)         non-capturing group
+  (re)           numbered capturing group (submatch)
+  (?P<name>re)   named & numbered capturing group (submatch)
+  (?:re)         non-capturing group (submatch)
   (?flags)       set flags within current group; non-capturing
   (?flags:re)    set flags during re; non-capturing