用正则表达式替换特定字符后的字符串?

时间:2019-07-17 09:31:50

标签: regex

实际值:Mission_Impossible 预期:已完成任务

2 个答案:

答案 0 :(得分:0)

因此,您想替换_之后的所有内容吗?
您可以尝试使用(?<=_)\w+,就像在此DEMO中一样。
它使用正向后向(look-behind)仅匹配遵循后向模式的字符串。

答案 1 :(得分:0)

查看此内容:

Pattern : [^_]+$

    Match 1
    Full match  27-37   Impossible
    Match 2
    Full match  46-56   Impossible
    Match 3
    Full match  65-75   Impossible
    Match 4
    Full match  84-94   Impossible
    Match 5
    Full match  103-113 Impossible

https://regex101.com/r/VPIQek/4