int a = Convert.ToInt32(txt1.Text.Trim().Replace('[', ']').Split(']')[1]);
string b = txt1.Text.Trim().Replace('[', ']').Split(']')[2];
string str = "[数字]字符串"; Regex reg = new Regex(@" ([^]+)\](.*)"); string a= Convert.ToInt32( reg.Match(str).Groups[1].Value); string b= Convert.ToInt32( reg.Match(str).Groups[2].Value);
string tempStr = "[数字]字符串"; string pattern = @" ([\s§]∗) ([\s\S]*)"; Regex re = new Regex(pattern); string str1 = Regex.Replace(tempStr,pattern,"$1"); string str2 = Regex.Replace(tempStr, pattern, "$2");
/// <summary>
/// 返回一个字符串数组
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
public string[] ReturnIDAndName(string str)
{
string[] stringArray = new string[2];
Regex reg = new Regex(@"
([^]+)\](.*)");
stringArray[0]= reg.Match(str).Groups[1].Value;
stringArray[1] = reg.Match(str).Groups[2].Value;
return stringArray;
}
/// <summary>
/// 截取字符串编号
/// </summary>
public int ReturnId(string str)
{
try
{
if (string.IsNullOrEmpty(str))
{
return 0;
}
Regex regex = new Regex("(?<=\\[)\\d+(?=\\])");
Match m = regex.Match(str);
int pid;
if (!m.Success)
{
pid = int.Parse("[" + regex.Match(str).Value + "]");
}
return int.Parse(regex.Match(str).Value);
}
catch
{
return 0;
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有