summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRex Kerr <ichoran@gmail.com>2014-06-26 19:01:10 -0700
committerRex Kerr <ichoran@gmail.com>2014-06-26 19:01:10 -0700
commitc51c5e14607ac78046f8610f61abcadc6262c340 (patch)
tree7ee36b23b6950234a439591fd6b117ace95de46a /src
parent0a67b3c75c10b1d5e6388b10797d4aa893655e5d (diff)
downloadscala-c51c5e14607ac78046f8610f61abcadc6262c340.tar.gz
scala-c51c5e14607ac78046f8610f61abcadc6262c340.tar.bz2
scala-c51c5e14607ac78046f8610f61abcadc6262c340.zip
SI-7562 Regex.findAllIn does not report all matches
Changed findAllIn docs to clarify that it finds non-overlapping matches.
Diffstat (limited to 'src')
-rw-r--r--src/library/scala/util/matching/Regex.scala10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/library/scala/util/matching/Regex.scala b/src/library/scala/util/matching/Regex.scala
index 6743b9e42a..f35ea566ba 100644
--- a/src/library/scala/util/matching/Regex.scala
+++ b/src/library/scala/util/matching/Regex.scala
@@ -274,12 +274,18 @@ class Regex private[matching](val pattern: Pattern, groupNames: String*) extends
// @see UnanchoredRegex
protected def runMatcher(m: Matcher) = m.matches()
- /** Return all matches of this regexp in given character sequence as a [[scala.util.matching.Regex.MatchIterator]],
+ /** Return all non-overlapping matches of this regexp in given character
+ * sequence as a [[scala.util.matching.Regex.MatchIterator]],
* which is a special [[scala.collection.Iterator]] that returns the
* matched strings, but can also be converted into a normal iterator
* that returns objects of type [[scala.util.matching.Regex.Match]]
* that can be queried for data such as the text that precedes the
* match, subgroups, etc.
+ *
+ * Where potential matches overlap, the first possible match is returned,
+ * followed by the next match that is completely after the first. For
+ * instance, `"hat[^a]+".r` will match `hath` and `hattth` in the string
+ * `"hathatthattthatttt"`.
*
* Attempting to retrieve information about a match before initializing
* the iterator can result in [[java.lang.IllegalStateException]]s. See
@@ -292,7 +298,7 @@ class Regex private[matching](val pattern: Pattern, groupNames: String*) extends
def findAllIn(source: CharSequence) = new Regex.MatchIterator(source, this, groupNames)
- /** Return all matches of this regexp in given character sequence as a
+ /** Return all non-overlapping matches of this regexp in given character sequence as a
* [[scala.collection.Iterator]] of [[scala.util.matching.Regex.Match]].
*
* @param source The text to match against.