且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

正则表达式来判断一个字符串不包含特定字符

更新时间:2022-11-12 09:58:31

您的解决方案是说对了一半。你看这场比赛是为其他字符。你想说的是像哎!我不想看到这个字符在整个字符串。

Your solution is half right. The match you see is for the other characters. What you want to say is something like "hey! I do not want to see this character in the entire string".

在你这种情况下:

Regex.IsMatch("103","^[^0]*$")