Reg EX [英] Reg EX

查看:120
本文介绍了Reg EX的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果你看下面的函数,它返回true但它应该返回false任何想法

字符串 v = " fff" ;

if you look at the function below it return true but it should return false any ideas 

string v = "fff";

bool IsWhiteSpace( string MyString)

bool IsWhiteSpace(string MyString)

{

正则表达式 reg = new 正则表达式 @" \s *" );

Regex reg = new Regex(@"\s*");

if (reg.IsMatch(MyString))

if (reg.IsMatch(MyString))

{

返回 true ;

return true;

}

else

else

{

return false ;

return false;

}

推荐答案

正则表达式正确执行。 \ * *表示匹配任何空格字符,例如空格,制表符和换行符任意数字包括无。因此它匹配,因为它没有找到任何字符。
Your regex performs correctly. \s* means match any whitespace characters, like spaces, tabs, and newlines any number of times including none. So it matches because it does not found any character.


这篇关于Reg EX的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆