Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- numericValues("a123 : 0 abc:123 123:abc xyz:1") // List(123, 1)
- def numericValues(text: String): List[Int] = {
- val regex = """([a-z]+)s*:s*(d+)""".r
- regex.findAllIn(s).flatMap(s => PartialFunction.condOpt(s) { case regex(_, num) => num })
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement