简体   繁体   English

使用正则表达式模式并获取CS1003:C#中的语法错误

[英]Using regex pattern and getting CS1003: Syntax error in C#

using @ but still error: 使用@但仍然错误:

错误

Does anyone see why this line: 有谁知道为什么这行:

String[] values = Regex.Split(line, @",(?! [\w\d\.\[\]\(\)\#\*\-_])(?=([^\"]*\"[^\"]*\")*[^\"]*$)");

Error CS1002 ; 错误CS1002; expected InsertLogtoDatabase D:\\MyProjects\\InsertLogWindowsApp\\WindowsFormsApplication1\\LogOrderi2trade.cs 119 预期的InsertLogtoDatabase D:\\ MyProjects \\ InsertLogWindowsApp \\ WindowsFormsApplication1 \\ LogOrderi2trade.cs 119

Severity Code Description Project File Line Error CS1003 Syntax error, ',' expected InsertLogtoDatabase D:\\MyProjects\\InsertLogWindowsApp\\WindowsFormsApplication1\\LogOrderi2trade.cs 119 严重性代码说明项目文件行错误CS1003语法错误“'”,预期为InsertLogtoDatabase D:\\ MyProjects \\ InsertLogWindowsApp \\ WindowsFormsApplication1 \\ LogOrderi2trade.cs 119

If you wanna use " with a verbatim string literal, you need to double it like "" 如果要在逐字字符串文字上使用" ,则需要将其像""一样加倍

String[] values = Regex.Split(line, @",(?! [\w\d.[]()#*-_])(?=([^\""]\""[^\""]\"")[^\""]$)");

From C# spec $2.4.4.5 String literals : 来自C#spec $ 2.4.4.5字符串文字

quote-escape-sequence: "" quote-escape-sequence: ""

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM