我需要检查一个字符串,看看它是否包含空格,返回等以外的任何内容。
在perl中,我用过:
if($val =~/^\s*$/) {...}
我如何在PowerShell中执行此操作?
答案 0 :(得分:10)
使用-match
运算符:
if ($test -match 'regex_here') { 'It matched' }
另请查看比较运算符的在线文档:http://technet.microsoft.com/en-us/library/hh847759.aspx
答案 1 :(得分:-1)
if(“〜/ ^ \ s * $ /”。ToCharArray() - 包含$ val){“...”}