The use of below regex
does not match value : charIntIntIntIntIntInt
:
val regex = "([a-zA-Z]\\d\\d\\d\\d\\d\\d)"
//> regex : String = ([a-zA-Z]\d\d\d\d\d\d)
val f = List("b111111").filter(fi => fi startsWith regex)
//> f : List[String] = List()
f
is an empty List, it should contain b111111
When I use this regex on https://www.regex101.com/ then it correctly matches the String.
Is there a problem with how I'm filtering ?
Need to use matches
instead of startsWith
This is detailed in String.class
This works :
val regex = "([a-zA-Z]\\d\\d\\d\\d\\d\\d)"
val f = List("b111111").filter(fi => fi matches regex)
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