不乱于心,不困于情。
不畏将来,不念过往。如此,安好。

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。

赞(1) 打赏
未经允许不得转载:seo优化_前端开发_渗透技术 » Powershell-正则表达式-匹配字符类

相关推荐

  • 暂无文章

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏