Skip to content

Instantly share code, notes, and snippets.

@goungoun
Created March 24, 2018 12:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save goungoun/5a4d3d9ba55ad82d449a4f2bab8c4b17 to your computer and use it in GitHub Desktop.
Save goungoun/5a4d3d9ba55ad82d449a4f2bab8c4b17 to your computer and use it in GitHub Desktop.
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!
}
@goungoun
Copy link
Author

original.findAllIn(url).toList //> res1: List[String] = List(http, www, google, com)
fix.findAllIn(url).toList //> res2: List[String] = List(http://www.google.com)

@goungoun
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment