+ 1
C# Regex
How can I match only letters and spaces? I've come up with [^A-Za-z] but I can't figure out spaces
4 Answers
+ 5
^[a-zA-Z\s]*$
^ means start of the string
\s means spaces
*$ means all what is in brackets till the last element of the string, last element also included
+ 1
Sebastian Pacurar \s matches any white space character including spaces, tabs, line breaks..
+ 1
Thanks guys, but I literally forgot about String.Split(), lol. I got it all figured out. Didn't even need to worry about spaces.
0
([A-Za-z ])+
A-Z matches character from A to Z
a-z matches character from a-z
matches space character
[] matches any character in the set
+ matches one or more of the preceding token
https://regexr.com/54si4