我想比较一个带双引号的字符串。我试了下面的代码,但是没有用。
样本$inputStr
为'{"to":"[Email]","from":"no-reply@mirvac.com","cc":"","bc":""'
$inputStr = '{"to":"[Email]","from":"no-reply@email.com","cc":"","bc":""'
$emailStr = '"[Email]"'
if ($inputStr -like "*"+$emailStr+"*") {
write-host "exists"
}
有什么建议吗?
谢啦,谢啦
1条答案
按热度按时间2lpgd9681#
比较不起作用,因为
[
和]
是wildcard characters,需要使用反勾号```('"
[Email]"'
)或WildcardPattern.Escape
method进行转义: