如何写个正则表达式,匹配出String中的这种类型的字符串。'1001234289','09023306001','寻找情人岛','付登高','none','2.00','2010-05-30','无线音乐榜','2008-10-25','','0','http://211.139.145.55:8080/colorring/al/600/902/0/0000/3306/001.wav','null','','1'

解决方案 »

  1.   

    匹配出String中的这种类型的字符串。 
    “这种字符串” 是指什么字符串?
      

  2.   


    1.匹配出 这样'1001234289','09023306001','寻找情人岛','付登高','none','2.00','2010-05-30'的字符串
    string input = "insert into tables values('1001234289','09023306001','寻找情人岛','付登高','none','2.00','2010-05-30','无线音乐榜','2008-10-25','','0','http://211.139.145.55:8080/colorring/al/600/902/0/0000/3306/001.wav','null','','1')";
    string output = Regex.Match(input, "(?n)'[^']*'(,'[^']*')*");
    //output: '1001234289','09023306001','寻找情人岛','付登高','none','2.00','2010-05-30','无线音乐榜','2008-10-25','','0','http://211.139.145.55:8080/colorring/al/600/902/0/0000/3306/001.wav','null','','1'2. 匹配1001234289这种用单引号引起来得数据
    string input = "insert into tables values('1001234289','09023306001','寻找情人岛','付登高','none','2.00','2010-05-30','无线音乐榜','2008-10-25','','0','http://211.139.145.55:8080/colorring/al/600/902/0/0000/3306/001.wav','null','','1')";
    Match m = Regex.Match(input, "'([^']*)'");
    while(m.Success)
    {
        Console.Writeline(m.Groups[1].Value);
        m = m.NextMatch();
    }