62,264
社区成员
发帖
与我相关
我的任务
分享using System;
using System.Text.RegularExpressions;
class Program
{
static void Main()
{
string s = "@RA@YA@L2@Q2@EA";
string s1 = Regex.Replace(s, @"@(.).", "$1");
string s2 = Regex.Replace(s, @"@.(.)", "$1");
Console.WriteLine(s1); // 输出:RYLQE
Console.WriteLine(s2); // 输出:AA22A
}
} string html = @"@RA@YA@L2@Q2@EA";
Regex reg = new Regex(@"(?<=\@(?<s1>\w{1}))\w{1}");
MatchCollection mc = reg.Matches(html);
Console.WriteLine("/*\n------输出结果------------");
string s1 = "";
string s2 = "";
foreach (Match m in mc)
{
s1 += m.Groups["s1"].ToString();
s2 += m.Groups[0].ToString();
}
Console.WriteLine(s1+"\n"+s2);
Console.WriteLine("*/");
/*
------输出结果------------
RYLQE
AA22A
*/