fork(7) download
  1. object Main extends App {
  2. val str = "Hello the cost is $323,999 and it has 3 modes 1,2, and 3"
  3. val pattern = """\$([0-9]+(?:,[0-9]+)*)""".r
  4. val replacedStr = pattern replaceAllIn (str, m => "\\$" + m.group(1).replace(",", ""))
  5. print(replacedStr);
  6. }
Success #stdin #stdout 0.38s 322496KB
stdin
Standard input is empty
stdout
Hello the cost is $323999 and it has 3 modes 1,2, and 3