I'm working on a project to perform a query
into a set of files
where the query criteria
are inputted by a user
.
Essentially, if the user inputs:
/T"some text"
The query will look for any file that contains "some text."
If a user inputs:
/T"some text" /T"some other text"
The query will look for a file that contains both or at least one such criteria.
I have a couple of ideas about how to perform the query itself, but my question is how can I extract the text
after the /T
and in-between the quotes
. I plan on putting the extracted string into some data structure.
I saw some examples of using IndexOf and such, but they would essentially look for the first instance of /T
and extract everything else after that. Is there a method that would allow a bounded way
of getting this information, whether it is some class or 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();