Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/20.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 - Fatal编程技术网

C# 如何在不返回标记的情况下返回两个标记之间的字符串(仅使用正则表达式)

C# 如何在不返回标记的情况下返回两个标记之间的字符串(仅使用正则表达式),c#,regex,C#,Regex,带括号返回:如何返回没有用于排序的标记的字符串?您可以使用 string x = "[string] two[string] (1thing)"; Regex sort1 = new Regex(@"\[(.*?)\]"); MatchCollection sortOpen = sort1.Matches(x); foreach (Match y in sortOpen) { ..

带括号返回:如何返回没有用于排序的标记的字符串?

您可以使用

        string x = "[string] two[string] (1thing)";
        Regex sort1 = new Regex(@"\[(.*?)\]");
        MatchCollection sortOpen = sort1.Matches(x);
        foreach (Match y in sortOpen)
        {
            ..
        }

(?是的,想解释一下吗?哈哈?
(?<=\[)(.*?)(?=\])