有没有办法在这样的字符串中进行替换?(这是简化的例子)
string input = "INSERT INTO blah VALUES \" blah blah \r\n \" \r\n (here can be anything like several new lines and \t tabs) INSERT INTO blah VALUES \" blah blah \r\n \" \r\n";
input.Replace("\r\n", "\n"); // this is just example, it doesn't work the way I need it
// and the output would look like this:
string output= "INSERT INTO blah VALUES \" blah blah \r\n \" \n INSERT INTO blah VALUES \" blah blah \r\n \" \n";
所以它只会在 SQL 命令之外替换新行?这可以使用正则表达式安全地实现吗?
编辑:替换必须可能通过 \r\n 来实现,到 \n 在 SQL 命令之间可能会有更多。命令没有精确地分开。
编辑:所以基本问题是 - 我如何只替换外部字符串?
string = "outer string \"inner string\" outer string \"inner string\" outer string"