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

时间:2023-05-29 20:06:44 


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
投稿

猜你喜欢

  • 浅谈Android性能优化之内存优化

    2023-08-19 04:36:43
  • Flutter图片缓存管理ImageCache原理分析

    2023-08-20 23:26:19
  • 轻松学习C#的结构和类

    2023-12-10 13:46:19
  • JAVA实现KMP算法理论和示例代码

    2021-08-06 07:13:44
  • 解决C#全屏幕截图的实现方法

    2023-10-25 00:41:15
  • C# 如何使用ajax请求

    2023-07-21 07:44:40
  • java eclipse 整个项目或包查找只定字符串并替换操作

    2022-10-20 18:35:56
  • C#字典Dictionary的用法说明(注重性能版)

    2023-08-05 19:33:02
  • SpringBoot Jpa分页查询配置方式解析

    2023-03-02 10:04:02
  • Android10 分区存储的适配规则

    2022-11-25 12:22:53
  • spring boot security设置忽略地址不生效的解决

    2022-06-07 16:37:30
  • android串口开发入门之搭建ndk开发环境及第一个jni调用程序

    2023-03-14 16:54:55
  • Java通过SSM完成水果商城批发平台流程

    2023-01-04 01:32:04
  • java实现单词小游戏

    2023-11-25 05:03:33
  • Android闹钟机制实现定时任务功能

    2021-08-06 07:36:03
  • Springboot jpa @Column命名大小写问题及解决

    2023-02-19 03:24:21
  • Android微信SDK实现分享

    2021-09-18 17:52:58
  • Java把数字格式化为货币字符串实例代码

    2022-10-13 23:17:27
  • 使用JAXBContext 设置xml节点属性

    2021-09-21 00:05:44
  • C语言实现贪吃蛇游戏演示

    2023-07-03 14:16:43
  • asp之家 软件编程 m.aspxhome.com