I’m trying to validate that a user inputs some text into a rich text box, on the server side. I don’t want to allow them to put in just HTML encoded spaces, either. I’m using an application’s built in regex validation, so I can’t have more than one pattern.
Is it possible to use only one C# regex for the following pattern?
Allow (one or more non white space characters). Don’t allow empty string:
^.*\S+.*$
-They need to enter some text. All white space not allowed:
!^\s+$
-Most likely white space will appear as . Don’t allow a string of only HTML space characters:
!^( )+$
I thought that this would work but it doesn’t:
^.*\S+$(!(^(\s+)+$))!(^( )+$)
So these two would be a valid strings:
'lorem ipsum'
'lorem ipsum'
Im not clear on what you are trying to capture… but does this work?
Matches:
"lorem""lorem ipsum""lorem ipsum"Doesn’t match:
""" "edited for comment