C# 判断字符串第一位是否为数字
程序员文章站
2023-12-18 23:07:58
复制代码 代码如下:using system;using system.collections.generic;using system.componentmodel;us...
复制代码 代码如下:
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( "大写");
}
}
}
}