views:

42

answers:

2

I'd like to setup a RegularExpressionValidator to ensure users are entering valid windows IDs in a textbox.

Specifically, I'd like to ensure it's any three capital letters (for our range of domains), followed by a backslash, followed by any number of letters and numbers.

Does anyone know where I can find some examples of this type of validation...or can somebody whip one up for me? :)

Language is VB.NET if it matters...

+1  A: 

This should do it.

^[A-Z]{3}\\[A-Za-z0-9]+$

You may be able to abbreviate. To embed in a string in C# (if that's your language) you need to escape the backslashes:

"^[A-Z]{3}\\\\[A-Za-z0-9]+$"

If you want to restrict to known domains then:

^((AAA)|(BBB)|(CCC))\\...
David M
it's vb.net if that matters
Albert
It doesn't - in fact, I've just noticed your talking about a RegularExpressionValidator, so you can ignore the C# comment.
David M
thats what i was thinking...since it's all in the markup code it doesn't matter. thanks!
Albert
+1  A: 

Try this regex

^[A-Z]{3}\\\w+$
Bryan Denny