C# 匹配?使用C使用regex#
我正在尝试使用正则表达式将此字符串“end='w'?>”与c中的匹配# 以下是我得到的: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
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)”