fork(2) download
  1. import scala.util.matching.Regex
  2. object Main extends App {
  3. var str = "key1=value1&key2=value2&key3=value3"
  4. val pattern = """key2=([^&]*)""".r.unanchored
  5. val res = str match {
  6. case pattern(res) => println(res)
  7. case _ => "No match"
  8. }
  9. }
Success #stdin #stdout 0.14s 322496KB
stdin
Standard input is empty
stdout
value2