regex check for white space in middle of string

前端 未结 5 1983
感情败类
感情败类 2020-12-16 14:08

I want to validate that the characters are alpha numeric:

Regex aNum = Regex(\"[a-z][A-Z][0-9]\");

I want to add the option that there migh

5条回答
  •  孤街浪徒
    2020-12-16 15:00

    [A-Za-z0-9\s]{1,} should work for you. It matches any string which contains alphanumeric or whitespace characters and is at least one char long. If you accept underscores, too you shorten it to [\w\s]{1,}.

    You should add ^ and $ to verify the whole string matches and not only a part of the string:

    ^[A-Za-z0-9\s]{1,}$ or ^[\w\s]{1,}$.

提交回复
热议问题