Reputation: 17
I need to build up a regular expression to match the following file name pattern:
EDI*.DAT
and at the same time it should exclude files with the following file name patterns as EDI*US*.DAT
and EDI*CA*.DAT
For example: Assume there are three files
"EDIabUS674.DAT" "EDIabcdCA1234.DAT" and "EDIabcIN987.DAT "
I need a regular expression to match for the file with name "EDIabcIN123.DAT" and at the same time should not match and exclude other two files "EDIabUS674.DAT" and "EDIabcdCA1234.DAT"
Any help on this is much appreciated!!
Upvotes: 0
Views: 54
Reputation: 163457
Maybe you can use 2 negative lookaheads to assert that the string does not contain CA
and US
:
Explanation
^
(?!.*CA)
(?!.*US)
\w+
(You can change this to for example [A-Za-z\d]+ if you don't want to match underscores)\.DAT
$
Upvotes: 1