views:

167

answers:

2

Hi all, i am using asp.net 3.5 and VB.net, i need a validation expression to validate a string of 1 to 50 characters, white spaces, numbers, special character are all allowed, simply, it should match an nvarchar(50) database field. it will be applied to a textbox, also, the same case but for 1-200 characters which will be validating a multi-line textbox..

Thanks in advance

+1  A: 

Do you mean that it just needs to ensure that there are between 1 and 50/200 characters in the strings?

If so, try these:

^[\s\S]{1,50}$
^[\s\S]{1,200}$

Testing for [\s\S] rather than [.] ensures that any newlines in the multiline textarea don't cause problems.

LukeH
Yes, also i am accepting any character that can be stored in an nvarchar database field.
Maen
+1  A: 

Have you looked at the following site which provides extensive tutorials and examples on regular expressions :-

http://www.regular-expressions.info/

cyberbobcat