fork(1) download
  1. object Main extends App {
  2. val num = Seq(2,3)
  3. val s = "1041=pqr\u000148=xyz\u000122=8\u00012=abc\u000148=123\u00013=def\u0001"
  4. val pattern = s"\\b(?:${num.mkString("|")})=[^\\u0001]*\\u0001*"
  5. // println(pattern) // => \b(?:2|3)=[^\u0001]*\u0001*
  6. println(s.replaceAll(pattern, ""))
  7. // => 1041=pqr\u000148=xyz\u000122=8\u000148=123\u0001
  8. }
Success #stdin #stdout 0.38s 4382720KB
stdin
Standard input is empty
stdout
1041=pqr48=xyz22=848=123