#regex #scala
We create a String and call the r( ) method on it. Scala implicitly converts the String to a RichString and invokes that method to get an instance of Regex.
If you want to change selection, open document below and click on "Move attachment"
Scala Regular Expressionstr = "Scala is Scalable and cool"
println(pattern findFirstIn str)
}
}
When the above code is compiled and executed, it produces the following result:
C:/>scalac Test.scala
C:/>scala Test
Some(Scala)
C:/>
<span>We create a String and call the r( ) method on it. Scala implicitly converts the String to a RichString and invokes that method to get an instance of Regex. To find a first match of the regular expression, simply call the findFirstIn() method. If instead of finding only the first occurrence we would like to find all occurrences of the matchi Summary
status | not read | | reprioritisations | |
---|
last reprioritisation on | | | suggested re-reading day | |
---|
started reading on | | | finished reading on | |
---|
Details