C# 判斷字符串第一位是否為數(shù)字
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( "是數(shù)字");
}
else if (regChina.IsMatch(str))
{
MessageBox.Show( "是中文");
}
else if (regChar.IsMatch(str))
{
MessageBox.Show( "小寫");
}
else if (regDChar.IsMatch(str))
{
MessageBox.Show( "大寫");
}
}
}
}
相關文章
基于C#實現(xiàn)的多生產(chǎn)者多消費者同步問題實例
這篇文章主要介紹了基于C#實現(xiàn)的多生產(chǎn)者多消費者同步問題,包括了加鎖與釋放鎖,以及對應臨界資源的訪問。是比較實用的技巧,需要的朋友可以參考下2014-09-09
C#12中的Collection expressions集合表達式語法糖詳解
C#12中引入了新的語法糖來創(chuàng)建常見的集合,并且可以使用..來解構集合,將其內(nèi)聯(lián)到另一個集合中,下面就跟隨小編一起學習一下C#12中這些語法糖的使用吧2023-11-11
C#使用遠程服務調(diào)用框架Apache Thrift
這篇文章介紹了C#使用遠程服務調(diào)用框架Apache Thrift的方法,文中通過示例代碼介紹的非常詳細。對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下2022-06-06

