C# 中的 Character classes函数

首页 / C#入门教程 / C# 中的 Character classes函数

字符类匹配一组字符中的任何一个。下表描述了字符类−

Character class Description Pattern Matches
[character_group] Matches any single character in character_group. By default, the match is case-sensitive. [mn] "m" in "mat" "m", "n" in "moon"
[^character_group] Negation: Matches any single character that is not in character_group. By default, characters incharacter_group are case-sensitive. [^aei] "v", "l" in "avail"
[ first - last ] Character range: Matches any single character in the range from first to last. [b-d] [b-d]irds Birds Cirds Dirds
. Wildcard: Matches any single character except\n. a.e "ave" in "have" "ate" in "mate"
\p{ name } Matches any single character in the Unicode general category or named block specified by name. \p{Lu} "C", "L" in "City Lights"
\P{ name } Matches any single character that is not in the Unicode general category or named block specified by name. \P{Lu} "i", "t", "y" in "City"
\w Matches any word character. \w "R", "o", "m" and "1" in "Room#1"
\W Matches any non-word character. \W "#" in "Room#1"
\s Matches any white-space character. \w\s "D " in "ID A1.3"
\S Matches any non-white-space character. \s\S " _" in "int __ctr"
\d Matches any decimal digit. \d "4" in "4 = IV"
\D Matches any character other than a decimal digit. \D " ", "=", " ", "I", "V" in "4 = IV"

祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)

技术教程推荐

邱岳的产品手记 -〔邱岳〕

张汉东的Rust实战课 -〔张汉东〕

MySQL 必知必会 -〔朱晓峰〕

讲好故事 -〔涵柏〕

数据分析思维课 -〔郭炜〕

HarmonyOS快速入门与实战 -〔QCon+案例研习社〕

Kubernetes入门实战课 -〔罗剑锋〕

计算机基础实战课 -〔彭东〕

PPT设计进阶 · 从基础操作到高级创意 -〔李金宝(Bobbie)〕

好记忆不如烂笔头。留下您的足迹吧 :)