File tree Expand file tree Collapse file tree 4 files changed +75
-1
lines changed
scala-2.11_2.12/scala/util/matching/compat
scala-2.13/scala/util/matching/compat
test/scala/scala/util/matching/compat Expand file tree Collapse file tree 4 files changed +75
-1
lines changed Original file line number Diff line number Diff line change @@ -82,7 +82,7 @@ lazy val compat = new MultiScalaCrossProject(
8282 sharedSourceDir / " scala-2.11_2.12"
8383 }
8484 },
85- versionPolicyIntention := Compatibility .BinaryAndSourceCompatible ,
85+ versionPolicyIntention := Compatibility .BinaryCompatible ,
8686 mimaBinaryIssueFilters ++= {
8787 import com .typesafe .tools .mima .core ._
8888 import com .typesafe .tools .mima .core .ProblemFilters ._
Original file line number Diff line number Diff line change 1+ /*
2+ * Scala (https://www.scala-lang.org)
3+ *
4+ * Copyright EPFL and Lightbend, Inc.
5+ *
6+ * Licensed under Apache License 2.0
7+ * (http://www.apache.org/licenses/LICENSE-2.0).
8+ *
9+ * See the NOTICE file distributed with this work for
10+ * additional information regarding copyright ownership.
11+ */
12+
13+ package scala .util .matching
14+
15+ package object compat {
16+ final implicit class RegexOps (val regex : Regex ) extends AnyVal {
17+
18+ /** Returns whether this `Regex` matches the given character sequence.
19+ *
20+ * Like the extractor, this method takes anchoring into account.
21+ *
22+ * @param source The text to match against
23+ * @return true if and only if `source` matches this `Regex`.
24+ * @see [[Regex#unanchored ]]
25+ * @example {{{"""\d+""".r matches "123" // returns true}}}
26+ */
27+ def matches (source : CharSequence ): Boolean = regex.pattern.matcher(source).matches()
28+ }
29+
30+ }
Original file line number Diff line number Diff line change 1+ /*
2+ * Scala (https://www.scala-lang.org)
3+ *
4+ * Copyright EPFL and Lightbend, Inc.
5+ *
6+ * Licensed under Apache License 2.0
7+ * (http://www.apache.org/licenses/LICENSE-2.0).
8+ *
9+ * See the NOTICE file distributed with this work for
10+ * additional information regarding copyright ownership.
11+ */
12+
13+ package scala .util .matching
14+
15+ package object compat {
16+ type Regex = scala.util.matching.Regex
17+ val Regex = scala.util.matching.Regex
18+ }
Original file line number Diff line number Diff line change 1+ /*
2+ * Scala (https://www.scala-lang.org)
3+ *
4+ * Copyright EPFL and Lightbend, Inc.
5+ *
6+ * Licensed under Apache License 2.0
7+ * (http://www.apache.org/licenses/LICENSE-2.0).
8+ *
9+ * See the NOTICE file distributed with this work for
10+ * additional information regarding copyright ownership.
11+ */
12+
13+ package scala .util .matching .compat
14+
15+ import org .junit .Assert ._
16+ import org .junit .Test
17+
18+ class RegexOpsTest {
19+
20+ @ Test
21+ def testMatches (): Unit = {
22+ assertTrue(" .*hello.*" .r.matches(" hey hello" ))
23+ assertFalse(" .*hello.*" .r.matches(" hey hop" ))
24+ }
25+
26+ }
You can’t perform that action at this time.
0 commit comments