lundi 29 novembre 2021

Java Regex pattern not working for filename matching

I am trying to pull filenames with the below pattern RID12345678_DLF0013B-P-21311118121541.txt RID123456789_DLF0013B-P-21311118121541.txt RID12345678_DLF0013B-I-21311118121541.txt

So below is the Regex pattern I gave

"([\w{11,12}]_DLF0013B-[I|P]-[\b\d{14}\b])" - This one throws error for the bold part saying illegal escape sequence.

If I get rid of \b - "([\w{11,12}]_POS340BN1-[I|P]-[\d{14}])" - this one picks below file even though there are 15 bytes after character P.

RID12345678__DLF0013B-P-213111181215410.txt

Please help!

Aucun commentaire:

Enregistrer un commentaire