Reputation: 370
As a Java developer learning Scala, I was surprised to find a separate Scala library for regular expressions. The major difference seems to me to be that a lot of the Scala operations return an Option[String]. Is that the key difference or is there more I'm missing there in how those libraries are used?
Upvotes: 3
Views: 1786
Reputation: 627087
See what it is written in the scala.util.matching.Regex
documentation:
This class delegates to the
java.util.regex
package of the Java Platform. See the documentation forjava.util.regex.Pattern
for details about the regular expression syntax for pattern strings.
So, the regex library used is java.util.regex
, thus, the syntax is the same and all the shortcomings are the same.
Just in Scala, you can use single backslashes inside triple quoted strings.
If you were to compare methods that you have in Scala, then there are some differences. A nice method is findAllIn
/findAllMatchIn
and some others.
Upvotes: 4