110,561
社区成员
发帖
与我相关
我的任务
分享
public static class Ext
{
public static bool StartsWith(this string s, params string[] prefix)
{
return prefix.Any(p => s.StartsWith(p));
}
}
//用法:
bool result = s.StartsWith("1", "400", "800", "30"); //是否以1或者400或者800或者30开头
Regex reg = new Regex(@"^(800|400|1).*");
string s = "400,800,1fdasdfasfas2423vcsa";
bool isTrue=s.StartsWith("400,800,1");
string str = "400526398|800046846|12365478965|33444425";
string[] arr = str.Split('|');
if (arr[0].StartsWith("400") && arr[1].StartsWith("800") && arr[2].StartsWith("1"))
{
arr[3] = "110" + arr[3];
string result = string.Join("|", arr);
}