tags:

views:

68

answers:

1

hi Guys,

I am using c# for programming!

I want to write one regular expression in c# which will check first and last space in a sentence and will allow spaces in between it as well as there should be minimumm 2 charater entry in field, no limit for maximum characters, no special keys are allowed (@,#,$ etc) characters allowed

Please suggests!

A: 

It's not really clear exactly what you want. Your comment -- contradicting the question itself -- suggests something like this, perhaps...

^[A-Za-z0-9]+(?:\s*[A-Za-z0-9]+)+$

This means that the string must start and end with an alphanumeric, and all characters except the first and last must be either alphanumeric or whitespace.

LukeH
there can be spaces in between the words like 'hello dear' is ok, howeve ' hello dear ' is not valid
MKS
@Solution: I've updated my answer.
LukeH