मुझे यह कोड नीचे दिया गया है जो सिंगल कोट्स के लिए काम करता है। यह एकल उद्धरण के बीच सभी शब्द पाता है। लेकिन मैं डबल कोट्स के साथ काम करने के लिए रेगेक्स को कैसे संशोधित करूं?Regex.Matchches सी # डबल कोट्स
कीवर्ड एक रूप पद
से आ रही है तो
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)
}
यह स्ट्रिंग में उद्धरण डाल करने के लिए काम नहीं करेंगे:
जिस स्थिति में आप इस तरह कुछ करने के लिए चाहते हो सकता है? @ -स्ट्रिंग्स उद्धरण के लिए \ "के बजाय \" उपयोग करते हैं। "@" "(। *?)" "" –