星空网 > 软件开发 > ASP.net

判断输入字符中包含汉字数目

 1 using System; 2 using System.Collections.Generic; 3 using System.ComponentModel; 4 using System.Data; 5 using System.Drawing; 6 using System.Text; 7 using System.Windows.Forms; 8 using System.Text.RegularExpressions; 9 using System.Collections;10 11 namespace Test1912 {13   public partial class Form1 : Form14   {15     public Form1()16     {17       InitializeComponent();//初始化窗体18     }19     private void button1_Click(object sender, EventArgs e)//button1的单击事件20     {21       ArrayList itemList = new ArrayList();//定义一个空数组22       CharEnumerator CEnumerator = textBox1.Text.GetEnumerator();//将textBox1的Text中的字符串给CEnumerator23       Regex regex = new Regex("^[\u4e00-\u9fa5]{0,}$");//定义一个正则表达式,这里是只允许输入汉字的意思。24       while (CEnumerator.MoveNext())//递增索引,指向下一个字符,如果没有下一个就停止循环。25       {26         if (regex.IsMatch(CEnumerator.Current.ToString(), 0))//如果CEnumerator的当前字符符合regex这个规则,那么就把这个字符插入到itemlist里面。27           itemList.Add(CEnumerator.Current.ToString());28         textBox2.Text = itemList.Count.ToString();//将itemList的项数显示到textBox2里面。29       }30     }31   }32 }

判断输入字符中包含汉字数目




原标题:判断输入字符中包含汉字数目

关键词:

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

Shopify网站布局关键词的10个位置,你想知道吗?:https://www.kjdsnews.com/a/699051.html
【建议收藏】Cdiscount常见问题详解:https://www.kjdsnews.com/a/699052.html
除了美客多,拉美还有什么低门槛入驻平台?:https://www.kjdsnews.com/a/699053.html
【全面解析】Coupang平台到底怎么样?:https://www.kjdsnews.com/a/699054.html
年销售额破4000万美金!来自阿里的小伙做了个家具独立站:https://www.kjdsnews.com/a/699055.html
Coupang店铺怎么做?如何快速上架产品出单?:https://www.kjdsnews.com/a/699056.html
武陵山大裂谷周围景点 武陵山大裂谷周围景点图片:https://www.vstour.cn/a/411233.html
南美旅游报价(探索南美洲的旅行费用):https://www.vstour.cn/a/411234.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流