PowerShell 比较运算符
示例
PowerShell比较运算符由前导破折号(-)和名称(eqforequal,gtforgreaterthan等)组成。
名称之前可以带有特殊字符以修改运算符的行为:
i # Case-Insensitive Explicit (-ieq) c # Case-Sensitive Explicit (-ceq)
如果未指定,则不区分大小写是默认值,(“a”-eq“A”)与(“a”-ieq“A”)相同。
简单比较运算符:
2 -eq 2 # Equal to (==) 2 -ne 4 # Not equal to (!=) 5 -gt 2 # Greater-than (>) 5 -ge 5 # Greater-than or equal to (>=) 5 -lt 10 # Less-than (<) 5 -le 5 # Less-than or equal to (<=)
字符串比较运算符:
"MyString" -like "*String" # Match using the wildcard character (*) "MyString" -notlike "Other*" # Does not match using the wildcard character (*) "MyString" -match "$String^" # Matches a string using regular expressions "MyString" -notmatch "$Other^" # Does not match a string using regular expressions
集合比较运算符:
"abc", "def" -contains "def" # Returns true when the value (right) is present
# in the array (left)
"abc", "def" -notcontains "123" # Returns true when the value (right) is not present
# in the array (left)
"def" -in "abc", "def" # Returns true when the value (left) is present
# in the array (right)
"123" -notin "abc", "def" # Returns true when the value (left) is not present
# in the array (right)
热门推荐
10 最美的留言祝福语简短
11 韩语贺卡祝福语简短版
12 保持快乐祝福语大全简短
13 母亲说生日祝福语 简短
14 赠男友祝福语大全简短
15 贺卡祝福语情侣搞笑简短
16 宝宝新年祝福语大全简短
17 祝贺新婚祝福语古代简短
18 侄儿生日祝福语简短独特