I have this regex. It’s supposed to match all one character, and also all one character along with a space.
For example:
wwwwwwww - MATCH
www wwwwww - MATCH
@@@@@ - MATCH
wwwwqq - NOT MATCH
wwww qqqq - NOT MATCH
But it’s not matching things like:
@@@@@@@
.......
What’s wrong with it? Here it is below:
var match = Regex.Match(message, @"^\s*(\w)(?:\1|\s)*$");
Because
@and.are not “word characters”. Couldn’t you just match with(.)?You could also try with
\S(non white-space character).