En-Motion
En-Motion

Reputation: 909

Regex: Make shorter

Can this be made any shorter:

^ABC-DEF-F1-[0-9]{8}-[0-9]{3}-[0-9]{12}-[0-9A-Za-z\-]+_[0-9]{4}_V1.DAT.gz$

It will match file like this:

ABC-DEF-F1-20140705-003-140705091256-IRPS-1_0088_V1.DAT.gz

Upvotes: 0

Views: 55

Answers (1)

lxg
lxg

Reputation: 13107

Ok, let's try.

^ABC-DEF-F1-\d{8}-\d{3}-\d{12}-[\w-]+_\d{4}_V1.DAT.gz$

Please note that the \w would also allow lowercase letters and underscores. If you want to avoid this, use:

^ABC-DEF-F1-\d{8}-\d{3}-\d{12}-[\dA-Z-]+_\d{4}_V1.DAT.gz$

Upvotes: 1

Related Questions