regex check for white space in middle of string

前端 未结 5 1977
感情败类
感情败类 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:04

    To not allow empty strings then

    Regex.IsMatch(s ?? "",@"^[\w\s]+$"); 
    

    and to allow empty strings

    Regex.IsMatch(s ?? "",@"^[\w\s]*$"); 
    

    I added the ?? "" as IsMatch does not accept null arguments

提交回复
热议问题