如何在标记后提取字符串?

How to extract string after a marker?

我正在开展一个项目,将 query 执行到 set of files,其中 query criteriauser 输入。

本质上,如果用户输入:

/T"some text"

查询将查找任何包含 "some text."

的文件

如果用户输入:

/T"some text"/T"some other text"

查询将查找同时包含或至少包含一个此类条件的文件。

我对如何执行查询本身有一些想法,但我的问题是我如何在 /T 之后和 the quotes 之间 extract the text。我计划将提取的字符串放入某种数据结构中。

我看到了一些使用 IndexOf 等的示例,但它们基本上会查找 /T 的第一个实例,然后提取其他所有实例。有没有一种方法可以让 bounded way 获取这些信息,无论是 class 还是 implementation of regex?

var input = "/T\"some text\" /T\"some other text\"";
var criterias = input.Split(new[] { "/T\"", "\"" }, StringSplitOptions.None)
                     .Where(x => !string.IsNullOrWhiteSpace(x))
                     .ToList();