Reputation: 917
I am want to implement some regex to test a valid filename as: ABCD-A-V1-02/27/2012
Where the first letter should not be more than 4 letters, the second group goes from A-to-Z and the V# like V1, V2, etc
Here is what I have until now, but in the reg tester does not work, I think I a missing something.
[a-zA-Z]{4}-[A-Z]{1}-V\d{0,9}[1-9])|(0[1-9])|(1[0-2]))\/(([0-9])|([0-2][0-9])|(3[0-1]))\/(([0-9][0-9])|([1-2][0,9][0-9][0-9]
Upvotes: 1
Views: 324
Reputation: 16606
Here's the problems I see based on your description:
'A'
)Try this:
@"[a-zA-Z]{1,4}-[A-Z]-V\d-\d{2}/\d{2}/\d{4}"
That breaks down as:
'V'
Obviously this won't ensure that the digits at the end represent a valid date.
Upvotes: 2
Reputation: 3440
also you can put ^...$
sign for just validate your desire pattern exactly
@"^[a-zA-Z]{1,4}-[A-Z]-V\d-\d{2}/\d{2}/\d{4}$"
it will just validate only your desire pattern , rest of all is invalid
valid : AAAa-aa-v232-12/12/2-2010
invlid: AAAa-aa-v232-12/12/2-20103343AAAA
Upvotes: 0