Regular Expression Confirmation Allow only character and space in Asp.net

hello to everyone who needs a check that can only check a character and space. no mater how much space and characters in the text box

I use this regexp check below. but it allows only one space between two words, but does not allow a third space for the third word.

([A-Za-z]) + ([A-Za-z] +)

How to allow only characters and spaces in a Regexp check?

+4
source share
3 answers

Try the following:

([A-Za-z])+( [A-Za-z]+)*
                       ^^ here

* . , +. , [ ]+ .

, , anchor ^ $ . ^...regex...$

+4
+1

try it

Regex.IsMatch(inputToValidate, @"^[a-zA-Z\s]+$")
+1
source

Source: https://habr.com/ru/post/1537193/


All Articles