Ho ottenuto questo codice di seguito che funziona per le virgolette singole. trova tutte le parole tra le virgolette singole. ma come modifico la regex per lavorare con virgolette doppie?Regex.Matches C# doppie virgolette
parole chiave è proveniente da un formulario posta
così
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)
}
Non sarebbe lavorare per mettere le virgolette nella stringa? @ -strings usa "" invece di \ "per le virgolette.' @ "" "(. *?)" "" ' –