📜  替换正则表达式组()java代码示例

📅  最后修改于: 2022-03-11 14:52:07.848000             🧑  作者: Mango

代码示例1
Pattern p = Pattern.compile("(\\d)(.*)(\\d)");
String input = "6 example input 4";
Matcher m = p.matcher(input);
if (m.find()) {
    // replace first number with "number" and second number with the first
    String output = m.replaceFirst("number $3$1");  // number 46
}