Skip to content

Commit 8039ba6

Browse files
committed
clarify code comment about Index in match
1 parent 05e6ac2 commit 8039ba6

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

match.go

+8-6
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ import (
66
)
77

88
// Match is a single regex result match that contains groups and repeated captures
9-
// -Groups
10-
// -Capture
9+
//
10+
// -Groups
11+
// -Capture
1112
type Match struct {
1213
Group //embeded group 0
1314

@@ -43,10 +44,10 @@ type Group struct {
4344
type Capture struct {
4445
// the original string
4546
text []rune
46-
// the position in the original string where the first character of
47-
// captured substring was found.
47+
// Index is the position in the underlying rune slice where the first character of
48+
// captured substring was found. Even if you pass in a string this will be in Runes.
4849
Index int
49-
// the length of the captured substring.
50+
// Length is the number of runes in the captured substring.
5051
Length int
5152
}
5253

@@ -187,7 +188,8 @@ func (m *Match) addMatch(c, start, l int) {
187188
}
188189

189190
// Nonpublic builder: Add a capture to balance the specified group. This is used by the
190-
// balanced match construct. (?<foo-foo2>...)
191+
//
192+
// balanced match construct. (?<foo-foo2>...)
191193
//
192194
// If there were no such thing as backtracking, this would be as simple as calling RemoveMatch(c).
193195
// However, since we have backtracking, we need to keep track of everything.

0 commit comments

Comments
 (0)