日期:2014-05-20  浏览次数:20851 次

求一正则,拿100分作为感谢!
var listIssue = [{"BonusNumberString":"7,1,5,3,7|2|5","BonusTime":"2011-10-13 00:40","IssueNumber":"20111013-008"},{"BonusNumberString":"7,7,4,4,6|2|5","BonusTime":"2011-10-13 00:35","IssueNumber":"20111013-007"},{"BonusNumberString":"1,3,7,6,8|2|5","BonusTime":"2011-10-13 00:30","IssueNumber":"20111013-006"},{"BonusNumberString":"2,3,9,3,6|2|5","BonusTime":"2011-10-13 00:25","IssueNumber":"20111013-005"},{"BonusNumberString":"7,0,3,2,4|2|5","BonusTime":"2011-10-13 00:20","IssueNumber":"20111013-004"},{"BonusNumberString":"2,9,6,7,2|2|5","BonusTime":"2011-10-13 00:15","IssueNumber":"20111013-003"},{"BonusNumberString":"8,8,1,8,2|2|5","BonusTime":"2011-10-13 00:10","IssueNumber":"20111013-002"},{"BonusNumberString":"1,9,7,6,3|2|5","BonusTime":"2011-10-13 00:05","IssueNumber":"20111013-001"},{"BonusNumberString":"9,4,1,2,8|2|5","BonusTime":"2011-10-13 00:00","IssueNumber":"20111012-120"}];

有这个字符串,从网页取回来的。

取得BonusNumberString:值1,BonusTime:值2,IssueNumber:值3,

取得这堆字符中的值1/值2/值3。以上只是小片数据,实际有很多的。

------解决方案--------------------
C# code

@"\"BonusNumberString\":\"(?<v1>[^\"]+)\",\"BonusTime\":\"(?<v2>[^\"]+)\",\"IssueNumber\":\"(?<v3>[^\"]+)\""

------解决方案--------------------
C# code

void Main()
{
     string str = @"var listIssue = [{""BonusNumberString"":""7,1,5,3,7|2|5"",""BonusTime"":""2011-10-13 00:40"",""IssueNumber"":""20111013-008""},{""BonusNumberString"":""7,7,4,4,6|2|5"",""BonusTime"":""2011-10-13 00:35"",""IssueNumber"":""20111013-007""},{""BonusNumberString"":""1,3,7,6,8|2|5"",""BonusTime"":""2011-10-13 00:30"",""IssueNumber"":""20111013-006""},{""BonusNumberString"":""2,3,9,3,6|2|5"",""BonusTime"":""2011-10-13 00:25"",""IssueNumber"":""20111013-005""},{""BonusNumberString"":""7,0,3,2,4|2|5"",""BonusTime"":""2011-10-13 00:20"",""IssueNumber"":""20111013-004""},{""BonusNumberString"":""2,9,6,7,2|2|5"",""BonusTime"":""2011-10-13 00:15"",""IssueNumber"":""20111013-003""},{""BonusNumberString"":""8,8,1,8,2|2|5"",""BonusTime"":""2011-10-13 00:10"",""IssueNumber"":""20111013-002""},{""BonusNumberString"":""1,9,7,6,3|2|5"",""BonusTime"":""2011-10-13 00:05"",""IssueNumber"":""20111013-001""},{""BonusNumberString"":""9,4,1,2,8|2|5"",""BonusTime"":""2011-10-13 00:00"",""IssueNumber"":""20111012-120""}];";
      foreach(Match m in Regex.Matches(str,@"(?i)BonusNumberString"":""([^""]+)""\W+BonusTime"":""([^""]+)""\W+IssueNumber"":""([^""]+)"))
      {
       Console.WriteLine("BonusNumberString: {0}\tBonusTime: {1}\tIssueNumber: {2}",m.Groups[1].Value,m.Groups[2].Value,m.Groups[3].Value);
      }
      
      /*
    BonusNumberString: 7,1,5,3,7|2|5    BonusTime: 2011-10-13 00:40    IssueNumber: 20111013-008
    BonusNumberString: 7,7,4,4,6|2|5    BonusTime: 2011-10-13 00:35    IssueNumber: 20111013-007
    BonusNumberString: 1,3,7,6,8|2|5    BonusTime: 2011-10-13 00:30    IssueNumber: 20111013-006
    BonusNumberString: 2,3,9,3,6|2|5    BonusTime: 2011-10-13 00:25    IssueNumber: 20111013-005
    BonusNumberString: 7,0,3,2,4|2|5    BonusTime: 2011-10-13 00:20    IssueNumber: 20111013-004
    BonusNumberString: 2,9,6,7,2|2|5    BonusTime: 2011-10-13 00:15    IssueNumber: 20111013-003
    BonusNumberString: 8,8,1,8,2|2|5    BonusTime: 2011-10-13 00:10    IssueNumber: 20111013-002
    BonusNumberString: 1,9,7,6,3|2|5    BonusTime: 2011-10-13 00:05    IssueNumber: 20111013-001
    BonusNumberString: 9,4,1,2,8|2|5    BonusTime: 2011-10-13 00:00    IssueNumber: 20111012-120
      */
}

------解决方案--------------------
http://blog.csdn.net/lxcnn/article/details/4756030