111,126
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string tempStr = " fff=\"xsdf\" aaa=\"asdf\" bbb=\"sadf\" ccc=\"7\" ddd=\"1,2,3,4,5\" eee=\"8\"";
Regex tempRegex = new Regex(@"\s([^=""]*)=""([^=""]*)""");
Dictionary<string, int> dictionary = new Dictionary<string, int>();
dictionary.Add("eee",1);
dictionary.Add("ccc",2);
dictionary.Add("bbb",3);
MatchCollection tmepMatchs = tempRegex.Matches(tempStr);
foreach (Match match in tmepMatchs)
{
//Console.Write(match.Value);
}
//上面的代码是按原顺序输出,现在要求按照字典中的配置输出。
//要求先按字典排列存在与字典中的,然后剩余的随便怎么追加到后面
Console.ReadKey();
}
}
}