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( "大寫");
}
}
}
}
相關(guān)文章
基于C#實(shí)現(xiàn)的多生產(chǎn)者多消費(fèi)者同步問題實(shí)例
這篇文章主要介紹了基于C#實(shí)現(xiàn)的多生產(chǎn)者多消費(fèi)者同步問題,包括了加鎖與釋放鎖,以及對應(yīng)臨界資源的訪問。是比較實(shí)用的技巧,需要的朋友可以參考下2014-09-09
C#讀取XML中元素和屬性值的實(shí)現(xiàn)代碼
用C#讀取xml有很多方式,這里我就先使用XmlDocument讀取Xml,用一段代碼遍歷所有元素,并打印student的所有屬性和子節(jié)點(diǎn)的值2013-04-04
C#12中的Collection expressions集合表達(dá)式語法糖詳解
C#12中引入了新的語法糖來創(chuàng)建常見的集合,并且可以使用..來解構(gòu)集合,將其內(nèi)聯(lián)到另一個(gè)集合中,下面就跟隨小編一起學(xué)習(xí)一下C#12中這些語法糖的使用吧2023-11-11
C#中TreeView節(jié)點(diǎn)的自定義繪制方法
這篇文章主要介紹了C#中TreeView節(jié)點(diǎn)的自定義繪制方法,實(shí)例展示了TreeView節(jié)點(diǎn)的操作技巧,需要的朋友可以參考下2015-02-02
C#使用遠(yuǎn)程服務(wù)調(diào)用框架Apache Thrift
這篇文章介紹了C#使用遠(yuǎn)程服務(wù)調(diào)用框架Apache Thrift的方法,文中通過示例代碼介紹的非常詳細(xì)。對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2022-06-06

