110,570
社区成员
发帖
与我相关
我的任务
分享
MatchCollection mc=Regex.Matches("你的串",@"^[^(]*(?=()|(?<=))[^)]*$");
str1=mc[0].Value;
str2=mc[1].Value;
Match m = Regex.Match(textBox1.Text, @"^(?<str1>[^(]*)(.*)(?<str2>.*)$");
str1=m.Groups["str1"].Value;
str2=m.Groups["str2"].Value;
@"(?<play1>[^()]+)\((?<play1No>\d+)\)\((?<play2No>\d+)\)(?<play2>[^()]+)");
string yourStr = "【獨步】豹子头(1)(2)こ流星こ,★神★波波";
Match mc = Regex.Match(yourStr, @"^(?<play1>[^()]+)\((?<play1No>\d+)\)\((?<play2No>\d+)\)(?<play2>[^()]+)$");
if (mc.Success)
{
MessageBox.Show(mc.Groups["play1"].Value); //选手1的名字
MessageBox.Show(mc.Groups["play1No"].Value); //选手1的编号
MessageBox.Show(mc.Groups["play2"].Value); //选手2的名字
MessageBox.Show(mc.Groups["play2No"].Value); //选手2的编号
}
Match m = Regex.Match("快乐鱼 (2) (4) 无影(男) ", @"^(?<player1>.*)([((]\d*[))]\s*){2}(?<player2>.*)$");
textBox2.Text = m.Groups["player1"].Value + Environment.NewLine + m.Groups["player2"].Value;