Created
March 24, 2018 12:30
-
-
Save goungoun/5a4d3d9ba55ad82d449a4f2bab8c4b17 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object regexpPractice { | |
println("src/main/scala/org/graphframes/pattern/patterns.scala") | |
//> src/main/scala/org/graphframes/pattern/patterns.scala | |
val original = "[a-zA-Z0-9_]+".r //> original : scala.util.matching.Regex = [a-zA-Z0-9_]+ | |
val fix = "[a-zA-Z0-9_.:/]+".r //> fix : scala.util.matching.Regex = [a-zA-Z0-9_.:/]+ | |
"http://www.google.com" match { | |
case original(_*) => "match!" | |
case fix(_*) => "fix match!" | |
case _ => "not match" | |
} //> res0: String = fix match! | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
original.findAllIn(url).toList //> res1: List[String] = List(http, www, google, com)
fix.findAllIn(url).toList //> res2: List[String] = List(http://www.google.com)