0

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

2 Answers 2

1
[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.

Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.