Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/272.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/16.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#regexp模式到<;id></id>;_C#_Regex - Fatal编程技术网

c#regexp模式到<;id></id>;

c#regexp模式到<;id></id>;,c#,regex,C#,Regex,我写了以下模式: @"<([0-9]+)>(.*?) < /$1>" @”(.*)“ 但它不起作用。 我怎样才能提到第一组 原文: "Method()<0>int x = 0; while(x < 10)<1>echo(x)< /1>< /0>" “Method()int x=0;while(x

我写了以下模式:

@"<([0-9]+)>(.*?) < /$1>"
@”(.*)
但它不起作用。 我怎样才能提到第一组

原文:

"Method()<0>int x = 0; while(x < 10)<1>echo(x)< /1>< /0>"
“Method()int x=0;while(x<10)echo(x)
那将是
\1
,注意空格。

另请参见:

我不认为
0
是XML的合法标记名,因此XML解析器可能会抱怨。即使正则表达式在这种情况下有效,也要仔细阅读为什么真正的正则表达式通常无法解析XML文件。@strager-很好,在编辑问题
:P
@strager之前,我没有看到这些。它不是标记名,而是node@Hamish格鲁比扬,我很清楚这一点@萨切特先生,什么?我不知道你在说什么。那么,你要找的是尖括号内的第一个数字?然后你还要捕获字符串的其余部分?如果在您的问题中还包括您希望捕获的来源的确切文本,则会有所帮助。请参考以下内容:。。。它不是xml,但很相似。这家伙说得有道理