gpt4 book ai didi

java - 正则表达式在java中失败

转载 作者:行者123 更新时间:2023-12-02 03:08:04 25 4
gpt4 key购买 nike

我的文件名以 %payslip%.xml.gpg 开头。

以下是可能的文件名示例:

Taswkly_payslips_Pay27.xml.gpg
exec_payslip.xml.gpg
Cairns_payslips_adv_P27.xml.gpg

您能帮我建议上述模式名称的正则表达式吗?

在上面的模式中,下面的事情是固定的,即

*payslip*.xml.gpg.

如有任何帮助,我们将不胜感激。

最佳答案

您可以使用此正则表达式:

^.*payslip.*\.xml\.gpg$

^ start of the line
.* any character multiple times
payslip the string "payslip"
.* any character multiple times
\. the "." character
xml the string "xml"
\. the "." character
gpg the string "gpg"
$ end of the line

另外不要忘记在java中转义它

^.*payslip.*\\.xml\\.gpg$

Working example

关于java - 正则表达式在java中失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41455558/

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