获取字符串。 在vs2008中string a = "中国|zg,法国|fg,美国|mg"string b = "zb,fg";根据 b字符串在a字符串中得到,返回结果是string c = "中国,法国"; 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 private void button1_Click(object sender, EventArgs e){ string a = "中国|zg,法国|fg,美国|mg"; string b = "zg,fg"; Match m = Regex.Match(a, @"(?n)\w+(?=\|(" + b.Replace(',', '|') + "))"); while (m.Success) { MessageBox.Show(m.Value); m = m.NextMatch(); }} string a = "中国|zg,法国|fg,美国|mg"string b = "zb,fg";a中没有zb啊! string a = "中国|zg,法国|fg,美国|mg"; string b = "zg,fg"; String[] arrA = a.Split(','); String[] arrB = b.Split(','); String res = ""; for (Int32 i = 0; i < arrB.Length; i++) { for (Int32 j = 0; j < arrA.Length; j++) { if (arrA[j].IndexOf(arrB[i]) > -1) { res += arrA[j].Substring(0,arrA[j].IndexOf('|')) + ","; } } } res = res.Trim(','); Console.WriteLine(res); string a = "中国|zg,法国|fg,美国|mg";string b = "zg,fg";string[] c=a.split(',');string re="";string[] d=b.split(',');foreach(string x in c){ for(int i=0;i<d.count;i++) { if(d[i]==x.subString(2,2)) { re=re+x } }}return re; 正则这东西不是很好理解虽然他很强是我的话也是split处理字符串了 【求助】Socket 网络程序:如何检测和限制自己占用的带宽? C#中关于限制往listbox中添加重复值的问题!急 判断构造函数 请问--- c#的安装程序,如何处理“修复安装”? 求助,一个算法编程 .net调用delphi的dll 的问题 c#如何获取调用者的信息 为什么下面这2句会出错? 如何对菜单集中处理?? MSchart的使用中一些问题 C# 一些默认按键的问题
{
string a = "中国|zg,法国|fg,美国|mg";
string b = "zg,fg";
Match m = Regex.Match(a, @"(?n)\w+(?=\|(" + b.Replace(',', '|') + "))");
while (m.Success)
{
MessageBox.Show(m.Value);
m = m.NextMatch();
}
}
string b = "zb,fg";
a中没有zb啊!
string a = "中国|zg,法国|fg,美国|mg";
string b = "zg,fg"; String[] arrA = a.Split(',');
String[] arrB = b.Split(',');
String res = "";
for (Int32 i = 0; i < arrB.Length; i++)
{
for (Int32 j = 0; j < arrA.Length; j++)
{
if (arrA[j].IndexOf(arrB[i]) > -1)
{
res += arrA[j].Substring(0,arrA[j].IndexOf('|')) + ",";
}
}
}
res = res.Trim(','); Console.WriteLine(res);
string b = "zg,fg";
string[] c=a.split(',');
string re="";
string[] d=b.split(',');
foreach(string x in c)
{
for(int i=0;i<d.count;i++)
{
if(d[i]==x.subString(2,2))
{
re=re+x
}
}
}
return re;
虽然他很强
是我的话也是split处理字符串了