PowerShell高级条件运算符及循环标签详解
1. 高级匹配运算符
- -match和-notmatch
- 语法 :
'String' -match 'Regex Expression' - 功能 :使用正则表达式在字符串中搜索模式。表达式左边是字符串,右边是正则表达式。当在左边解析数组时,
-match的功能类似于-like,会输出定义数组中的每个匹配值。 - 示例 :
- 语法 :
# Example 1: Standard Match
$string = 'this is a string'
$string -match '.+'
# Example 2: Array Match
$arr = 'this is a string', 'this also is a string'
$arr -match '.+'
- **输出**:
# Example 1:
True
# Example 2:
this is a string
this also is a string
超级会员免费看
订阅专栏 解锁全文
1万+

被折叠的 条评论
为什么被折叠?



