Created
April 12, 2019 01:44
-
-
Save marcolivierarsenault/fcad2f29903c27ef06fab16a02d12729 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
def findMatchingPatterns(regexes: ArrayList[String]): UserDefinedFunction = { | |
udf((value: String) => { | |
for { | |
text <- Option(value) | |
matches = regexes.asScala.filter(r => Pattern.matches(r, text)) | |
if matches.nonEmpty | |
} yield matches | |
}, ArrayType(StringType)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment