喜欢使用Powershell不能按预期工作 [英] Like is not working as expected using Powershell
问题描述
我在for循环中有两个变量,如下所示
$ resourcename,$ SearchTextBox
例如,如果$ SearchTextBox是Abhishek而$ resourcename是Abhishek Srivastava
我使用like运算符来匹配字符串中的字符串,如下所示
if($ resourcename,$ SearchTextBox -like" *" + $ SearchTextBox +" *")
它返回true但不幸的是,即使$ SearchTextBox是Abhi然后它也回归真实
如果我犯了任何错误,请告诉我。
问候,
Sudheer
谢谢和问候,Sudheer
Hi Sudheer。
如果源字符串(
中的那个字符串,则like运算符返回true
SearchTextBox变量)将通配符与其比较的通配符与(
resourcename变量):
因此,如果
Hi,
I have two variables in the for loop as below
$resourcename,$SearchTextBox
For example if $SearchTextBox is Abhishek and $resourcename is Abhishek Srivastava
I am using like operator to match string inside string as below
if($resourcename,$SearchTextBox -like "*"+$SearchTextBox+"*")
Its returning true but unfortunately even if $SearchTextBox is Abhi then also it is returning true
Please let me know if I am making any mistake.
Regards,
Sudheer
Thanks & Regards, Sudheer
Hi Sudheer.
The like operator returns true if the source string (the one in the
SearchTextBox variable) matches wildcard to the one it is compared against (the one in the
resourcename variable): therefore, if the
这篇关于喜欢使用Powershell不能按预期工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!