小编use*_*813的帖子

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 …
Run Code Online (Sandbox Code Playgroud)

.net c# regex

12
推荐指数
4
解决办法
5万
查看次数

标签 统计

.net ×1

c# ×1

regex ×1