更新时间:2023-02-18 08:17:57
是的,Regex#replaceAllIn
有一个重载版本,它接受一个函数 Match =>字符串
.您的代码的等效 Scala 版本将是:
Yes, Regex#replaceAllIn
has an overloaded version that takes a function Match => String
. The equivalent Scala version of your code would be:
"""\d+""".r.replaceAllIn("one1two2three", m => (m.group(0).toInt + 1).toString)