Я получил этот код ниже, который работает для одинарных кавычек. находит все слова между одинарными кавычками. но как я могу изменить регулярное выражение для работы с двойными кавычками?Regex.Matches C# двойные кавычки
ключевых слова исходят от формы поста
так
keywords = 'peace "this world" would be "and then" some'
// Match all quoted fields
MatchCollection col = Regex.Matches(keywords, @"'(.*?)'");
// Copy groups to a string[] array
string[] fields = new string[col.Count];
for (int i = 0; i < fields.Length; i++)
{
fields[i] = col[i].Groups[1].Value; // (Index 1 is the first group)
}// Match all quoted fields
MatchCollection col = Regex.Matches(keywords, @"'(.*?)'");
// Copy groups to a string[] array
string[] fields = new string[col.Count];
for (int i = 0; i < fields.Length; i++)
{
fields[i] = col[i].Groups[1].Value; // (Index 1 is the first group)
}
Не было бы работать, чтобы поставить кавычки в строке? @ -strings используют «" вместо \ "для цитат.' @ "" "(. *?)" "" ' –