- PowerShell 教程
- PowerShell - 主页
- PowerShell - 概述
- PowerShell - 环境设置
- PowerShell - 命令行
- PowerShell - 文件和文件夹
- PowerShell - 日期和计时器
- PowerShell - 文件 I/O
- PowerShell - 高级命令行
- PowerShell - 脚本
- PowerShell - 特殊变量
- PowerShell - 运算符
- PowerShell - 循环
- PowerShell - 条件
- PowerShell - 数组
- PowerShell - 哈希表
- PowerShell - 正则表达式
- PowerShell - 反引号
- PowerShell - 方括号
- PowerShell - 别名
- PowerShell 有用资源
- PowerShell - 快速指南
- PowerShell - 有用资源
- PowerShell - 讨论
Powershell - 正则表达式 - 匹配字符类
以下是 Windows PowerShell 中支持的字符类的示例
##Format: \p{name}
#Logic: Matches any character in the named character class specified by
# {name}. Supported names are Unicode groups and block ranges such
# as Ll, Nd, Z, IsGreek, and IsBoxDrawing.
"abcd defg" -match "\p{Ll}+"
#Format: \P{name}
#Logic: Matches text not included in the groups and block ranges specified
# in {name}.
1234 -match "\P{Ll}+"
#Format: \w
#Logic: Matches any word character. Equivalent to the Unicode character
# categories [\p{Ll}\p{Lu}\p{Lt}\p{Lo}\p{Nd}\p{Pc}]. If ECMAScript-
# compliant behavior is specified with the ECMAScript option, \w is
# equivalent to [a-zA-Z_0-9].
"abcd defg" -match "\w+" #(this matches abcd)
#Format: \W
#Logic: Matches any nonword character. Equivalent to the Unicode categories
# [^\p{Ll}\p{Lu}\p{Lt}\p{Lo}\p{Nd}\p{Pc}].
"abcd defg" -match "\W+" #(this matches the space)
#Format: \s
#Logic: Matches any white-space character. Equivalent to the Unicode
# character categories [\f\n\r\t\v\x85\p{Z}].
"abcd defg" -match "\s+"
#Format: \S
#Logic: Matches any non-white-space character. Equivalent to the Unicode
# character categories [^\f\n\r\t\v\x85\p{Z}].
"abcd defg" -match "\S+"
#Format: \d
#Logic: Matches any decimal digit. Equivalent to \p{Nd} for Unicode and
# [0-9] for non-Unicode behavior.
12345 -match "\d+"
#Format: \D
#Logic: Matches any nondigit. Equivalent to \P{Nd} for Unicode and [^0-9]
# for non-Unicode behavior.
"abcd" -match "\D+"
以上所有命令的输出都为 True。
powershell_regex.htm
广告