正则表达式在java中失败
我有一个文件名,以%payslip%.xml.gpg开头 以下是可能的文件名示例:正则表达式在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
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
,当然,如果您使用字符串类的匹配方法,您不需要^
和$
。当然,如果使用字符串
类的匹配
方法,则不需要^
和$
。