我想要一个正则表达式模式来匹配具有以下模式的文本文件中的所有行:
TcQuery {dynamic_content} Alias "{dynamic_content}" New
如果文本文件有这两行:
//tcquery c_query alias "qrybklog" new <= This one shouldn´t be found because there is two backslashes before TcQuery.
tcquery c_query alias "qrybklog" new <= I want a pattern to match this line
我试过了,但两条线都匹配:
var prw = System.IO.File.ReadAllText(@"d:\backlog.prw", Encoding.ASCII);
prw = "//TcQuery c_query Alias teste1 new";
prw = "\nTcQuery c_query Alias teste2 new";
prw = "\nTcQuery c_query Alias teste3 new";
prw = "\n//TcQuery c_query Alias teste4 new";
var regexTcQuery = new Regex("TcQuery+[ *]+[0-9a-zA-Z_]+[ *]+alias+[ *]+[0-9a-zA-Z_\"]+[ *]new$", RegexOptions.IgnoreCase);
var resultTcQuery = regexTcQuery.Matches(prw);