gpt4 book ai didi

java - 正则表达式在最后一次出现大于符号(>)/任何特殊字符后提取值并删除数字

转载 作者:行者123 更新时间:2023-12-02 02:51:00 26 4
gpt4 key购买 nike

示例:

<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..

输出:

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

最佳答案

在这种情况下,* 运算符的正常贪婪行为对您有利。您可以简单地使用以下正则表达式模式:

.*>(.*)

这里,.*> 将消耗所有内容,直到并包括最后右括号。然后,我们捕获字符串的其余部分。

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

关于java - 正则表达式在最后一次出现大于符号(>)/任何特殊字符后提取值并删除数字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43847249/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com