源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

C# 判断字符串第一位是否为数字

  • 时间:2021-12-06 18:14 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:C# 判断字符串第一位是否为数字
[u]复制代码[/u] 代码如下:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Text.RegularExpressions; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { Regex regChina = new Regex( "^[^\x00-\xFF]"); Regex regNum = new Regex( "^[0-9]"); Regex regChar = new Regex( "^[a-z]"); Regex regDChar = new Regex( "^[A-Z]"); string str = "YL闫磊"; if (regNum.IsMatch(str)) { MessageBox.Show( "是数字"); } else if (regChina.IsMatch(str)) { MessageBox.Show( "是中文"); } else if (regChar.IsMatch(str)) { MessageBox.Show( "小写"); } else if (regDChar.IsMatch(str)) { MessageBox.Show( "大写"); } } } }
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部