Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/18.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# Regex解析两个标记之间的字符串,而不包含捕获组和排除标记_C#_Regex - Fatal编程技术网

C# Regex解析两个标记之间的字符串,而不包含捕获组和排除标记

C# Regex解析两个标记之间的字符串,而不包含捕获组和排除标记,c#,regex,C#,Regex,使用字符串集合,如下所示: string s1=“Identifier1=Value1##Comment”; string s2=“Something=SomeData”; string s3=“Name=information\\t\\t\\t###更多评论!”; 字符串s4=“Nam2=信息”; 我需要一个正则表达式模式,该模式将捕获等号(=)之后的行上的所有信息,直到行的末尾或##注释标记,但不捕获其中任何一个 给我(分别): 到目前为止我已经想到了:(?##|$) 它在某种程度上是有效

使用字符串集合,如下所示:

string s1=“Identifier1=Value1##Comment”;
string s2=“Something=SomeData”;
string s3=“Name=information\\t\\t\\t###更多评论!”;
字符串s4=“Nam2=信息”;
我需要一个正则表达式模式,该模式将捕获等号(=)之后的行上的所有信息,直到行的末尾或##注释标记,但不捕获其中任何一个

给我(分别):

到目前为止我已经想到了:
(?##|$)

它在某种程度上是有效的,因为它能够抓取=符号后的所有文本直到字符串的结尾,但是当有注释标记时它就不起作用了:##,因为它会一直抓取到字符串的结尾,而不是停在##

…如果我将模式更改为:
(?),则可以使用此正则表达式(如使用中所示):


(?您可以使用此正则表达式

(?<==).*?(?=#{2}|$)

(?好吧,好吧,它确实有效!尽管我仍在努力找出如何/为什么!(另外,谢谢你的链接!现在我知道它叫什么了,我正在寻找关于它的帮助参考资料。在不知道这个词的情况下,我完全是在寻找解决方案!)
(?<==)(?:(?!#{2}).)*
(?<==).*?(?=#{2}|$)