连续11个字符呗。string s = "189841231331322091330515839747892151973587791373142400413098053606"; System.Text.RegularExpressions.MatchCollection mc = System.Text.RegularExpressions.Regex.Matches(s, @"\d{11}"); List<string> tels = new List<string>(); foreach (Match m in mc) { tels.Add(m.Value); } tels 就是你要的
string s = "189841231331322091330515839747892151973587791373142400413098053606"; s = System.Text.RegularExpressions.Regex.Replace(s, @"(\d{11})","'$1',"); s = s.SubString(0, s.Length-1);这样就可以得到你想要的结果了
string str = "12345"; string Result = ""; for (int i = 0; i < str.Length - 1; i++) { Result += "‘" + str[i] + "’,"; } Result += "‘" + str[str.Length - 1] + "’"; Response.Write(Result);
public string subStr() { string str = "189841231331322091330515839747892151973587791373142400413098053606"; string newStr = ""; if (str.Length / 11 > 1) { for (int i = 0; i <= str.Length / 11 - 1; i++) { newStr += "'" + str.Substring(i * 11, 11) + "',"; } } return newStr.Remove(newStr .Length -1); }
char[] a = "12345".ToCharArray(); String str=""; for(int i=0;i<a.Length;i++) { if (i == 0) { str = str + a[i].ToString(); } else { str = str +","+ a[i].ToString(); }
简单
{
string Temp_Str = string.Empty;
char[] CH_List=Str.ToCharArray();
for (int i = 0; i < CH_List.Length; i++)
{
Temp_Str += "'" + CH_List[i] + "',";
}
Temp_Str = Temp_Str.TrimEnd(',');
return Temp_Str;
}
{
string Temp_Str = string.Empty;
char[] CH_List = Str.ToCharArray();
for (int i = 0; i < CH_List.Length; i++)
{
Temp_Str += "'" + CH_List[i] + "',";
}
Temp_Str = Temp_Str.TrimEnd(',');
return Temp_Str.ToCharArray();
}
string result = string.Join(",", list.ConvertAll(delegate(string s) { return string.Format("'{0}'", s); }).ToArray());
String str = "1001,1002,1003";
str = String.Join("','",str.Split(new char[]{','},StringSplitOptions.RemoveEmptyEntries));
str = "'" + str + "'";
string[] a;
……//定义一个你所需大小的字符串数组
for(int i=0;i<=str.Length-11;i=i+11)
{
a[n]=str.Substring(i,11);
n++;
}
System.Text.RegularExpressions.MatchCollection mc = System.Text.RegularExpressions.Regex.Matches(s, @"\d{11}");
List<string> tels = new List<string>();
foreach (Match m in mc)
{
tels.Add(m.Value);
}
tels 就是你要的
string str="189841231331322091330515839747892151973587791373142400413098053606";
string newStr="";
for(int i=0;i<=str.Length-1;i++)
{
newStr+="'"+str.Substring(i*11,11)+"',";
}
{
string str = "189841231331322091330515839747892151973587791373142400413098053606";
string newStr = "";
if(str.Length/11>1)
{
for (int i = 0; i <= str.Length/11 - 1; i++)
{
newStr += "'" + str.Substring(i * 11, 11) + "',";
}
}
return newStr;
}
s = System.Text.RegularExpressions.Regex.Replace(s, @"(\d{11})","'$1',");
s = s.SubString(0, s.Length-1);这样就可以得到你想要的结果了
string str = "12345";
string Result = ""; for (int i = 0; i < str.Length - 1; i++)
{
Result += "‘" + str[i] + "’,";
}
Result += "‘" + str[str.Length - 1] + "’"; Response.Write(Result);
{
string str = "189841231331322091330515839747892151973587791373142400413098053606";
string newStr = "";
if (str.Length / 11 > 1)
{
for (int i = 0; i <= str.Length / 11 - 1; i++)
{
newStr += "'" + str.Substring(i * 11, 11) + "',";
}
}
return newStr.Remove(newStr .Length -1); }
String str="";
for(int i=0;i<a.Length;i++)
{
if (i == 0)
{
str = str + a[i].ToString();
}
else
{
str = str +","+ a[i].ToString();
}
}
str值就是‘1’,‘2’,‘3’,‘4’,‘5’