Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/257.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 匹配?使用C使用regex#_C#_Regex - Fatal编程技术网

C# 匹配?使用C使用regex#

C# 匹配?使用C使用regex#,c#,regex,C#,Regex,我正在尝试使用正则表达式将此字符串“end='w'?>”与c中的匹配# 以下是我得到的: Regex regexcontentLength = new Regex(@"(?<=end='w'\?>)(.*?)(?=\r\n--)"); contentLengthMatch = regexcontentLength.Match(content); Regex regexcontentLength=new Regex(@“(?)(.*?(=\r\n--”); contentLength

我正在尝试使用正则表达式将此字符串“end='w'?>”与c中的匹配# 以下是我得到的:

Regex regexcontentLength = new Regex(@"(?<=end='w'\?>)(.*?)(?=\r\n--)");
contentLengthMatch = regexcontentLength.Match(content);
Regex regexcontentLength=new Regex(@“(?)(.*?(=\r\n--”);
contentLengthMatch=regexcontentLength.Match(内容);
我认为是“?”问题导致我无法匹配。我尝试了多种组合,但似乎无法匹配。我指出了正确的方向,希望能帮上大忙

试试看

@"(?s)(?<=end='w'\?>)(.*?)(?=\r\n--)"
@“(?s)(?)(.*?(=\r\n-)”

使
匹配新行。

您想匹配什么?输入字符串是什么?如果要匹配文本
,则应使用
\?
@MatiCicero-字符串包含:“end='w'?>”和“\r\n--”并且我想获取介于两者之间的所有内容。这是一个图像文件,中间的数据是经过编码的,所以没有必要发布整个字符串,它真的很大?它不起作用了。正如您在上面的代码片段中所看到的,请尝试使用
@“(?s)(?)(.*?)(=\r\n-)”
。让
匹配一个新行。我试一试。我让你知道它在几分钟内是否有效。你给我的答案是在正则表达式中加上“(?s)”