Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
正则表达式在java中失败_Java_Regex_Regex Lookarounds - Fatal编程技术网

正则表达式在java中失败

正则表达式在java中失败,java,regex,regex-lookarounds,Java,Regex,Regex Lookarounds,我有一个文件名,以%payslip%.xml.gpg开头 以下是可能的文件名示例: Taswkly_payslips_Pay27.xml.gpg exec_payslip.xml.gpg Cairns_payslips_adv_P27.xml.gpg 你能帮我推荐上面图案名称的正则表达式吗 在上面的模式下,事情是固定的,即 *payslip*.xml.gpg. 任何帮助都将不胜感激。您可以使用此正则表达式: ^.*payslip.*\.xml\.gpg$ ^ star

我有一个文件名,以%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$

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

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

试试
*payslip.\\\\.xml\\.gpg
试试
*payslip.\\\.xml\\.gpg
,当然,如果您使用
字符串
类的
匹配方法,您不需要
^
$
。当然,如果使用
字符串
类的
匹配
方法,则不需要
^
$