有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!


共 (1) 个答案

  1. # 1 楼答案

    在本例中,*操作符的正常贪婪行为对您有利。您可以简单地使用以下正则表达式模式:

    .*>(.*)
    

    在这里,.*>将消耗所有内容,包括最后一个结束括号。然后,我们捕获字符串的剩余部分

    String input = "<E72327> An exception occurred within fCMN_TREProductInstanceCreate& while calling EV_ProdInstInsert&: <E05560> This Product Instance does not reference a Customer 8482195 that covers the entire duration..";
    input = input.replaceAll(".*>(.*)", "$1")
                 .replaceAll("\\d+\\s*", "");
    System.out.println(input);
    

    输出:

     This Product Instance does not reference a Customer that covers the entire duration..
    

    此处演示:

    Rextester