tags:

views:

14

answers:

2

how can i create a regular expression for abcABC123/abcABC123 in dataannotion

+1  A: 
[RegularExpression(
    @"^[a-zA-Z0-9]{1,9}/[a-zA-Z0-9]{1,9}$", 
    ErrorMessage = "Invalid format")]
public string Foo { get; set; }

You may adjust as necessary the min and max length of each part and the set of accepted characters.

Darin Dimitrov
A: 

I'd recommend you have a look at this article on .NET 3.5 DataAnnotations. It has a single example of usage of regular expression for validation. Your's string can be matched by [a-z]{3}[A-Z]{3}[0-9]{3}/[a-z]{3}[A-Z]{3}[0-9]{3} or something more general, like the one posted by Darin.

vlood