0

I have a file name which starts with %payslip%.xml.gpg.

Below are the possible file name example :

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

Could you please help me suggesting the regex for above pattern name.

In the above pattern below things are fixed i.e.

*payslip*.xml.gpg.

Any help would be appreciated.

1
  • 2
    try .*payslip.*\\.xml\\.gpg Commented Jan 4, 2017 at 3:00

1 Answer 1

2

You can use this regex:

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

Also don't forget to escape it in java

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

Working example

Sign up to request clarification or add additional context in comments.

1 Comment

And of course, you don't need ^ and $ if you're using the matches method of the String class.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.