In Scala I am trying to detemine the number of types a particular match is found (and it can occur several times in the same string). Namely, something that is of form "##/nnn-#" where # is a number 0-9
and n is a letter A-Za-z
and - is a hiphen and / is a forward slash.
You mean something like this?
scala> val reg = "[0-9]{2}/[a-zA-Z]{3}-[0-9]".r
scala> val str = "12/abc-2 abcd 55/bar-2 foo bar"
scala> reg.findAllIn(str).length
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With