string s="hi,你好123";
如何只输出数字、字母、汉字?
c# 字符串如何用Regex方法只输出数字、字母、汉字
答案:1 悬赏:40
解决时间 2021-02-22 19:22
- 提问者网友:优雅ぉ小姐
- 2021-02-22 14:19
最佳答案
- 二级知识专家网友:情战凌云蔡小葵
- 2021-02-22 14:40
// 数字 "\d+"
// 字母 "[a-zA-Z]+"
// 汉字 "[\u4e00-\u9fbb]+"
// 使用方法如下
string s = "hi,你好123";
var match = Regex.Match(s, @"\d+");
while (match.Success)
{
System.Diagnostics.Debug.WriteLine("找到字符:" + match.Value);
match = match.NextMatch();
}
// 字母 "[a-zA-Z]+"
// 汉字 "[\u4e00-\u9fbb]+"
// 使用方法如下
string s = "hi,你好123";
var match = Regex.Match(s, @"\d+");
while (match.Success)
{
System.Diagnostics.Debug.WriteLine("找到字符:" + match.Value);
match = match.NextMatch();
}
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯