正则表达式在java中失败

yhxst69z  于 2021-07-09  发布在  Java
关注(0)|答案(1)|浏览(309)

我有一个以%payslip%.xml.gpg开头的文件名。
下面是可能的文件名示例:

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

你能帮我建议一下上述模式名称的正则表达式吗。
在上面的模式下,事情是固定的,即。


* payslip*.xml.gpg.

任何帮助都将不胜感激。

bmp9r5qi

bmp9r5qi1#

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

^.*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$

工作示例

相关问题