- public static string Contentextract()
- {
- string result = "";
- string str = "大家好! <User EntryTime='2010-10-7' Email='zhangsan@163.com'>张三</User> 自我介绍。";
- Regex regex = new Regex(@"<User\s*EntryTime='(?<time>[\s\S]*?)'\s+Email='(?<email>[\s\S]*?)'>(?<userName>[\s\S]*?)</User>", RegexOptions.IgnoreCase);
- Match match = regex.Match(str);
- if(match.Success)
- {
- string userName = match.Groups["userName"].Value;
- string time = match.Groups["time"].Value;
- string email = match.Groups["email"].Value;
- string strFormat = String.Format("我是:{0},入职时间:{1},邮箱:{2}", userName, time, email);
- result = regex.Replace(str, strFormat);
- Console.WriteLine(result);
- }
- return result;
- }
posted @
2014-11-03 17:17
M i S s
阅读(
858)
评论()
编辑
收藏
举报