正则表达式:C#在双引号内提取文本

前端之家收集整理的这篇文章主要介绍了正则表达式:C#在双引号内提取文本前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我想提取双引号内的那些单词。所以,如果内容是:

Would “you” like to have responses to your “questions” sent to you via email?

答案必须是

>你
>问题

尝试这个正则表达式:
\"[^\"]*\"

要么

\".*?\"

解释:

[^ character_group ]

Negation: Matches any single character that is not in character_group.

*?

Matches the prevIoUs element zero or more times,but as few times as possible.

和一个示例代码

foreach(Match match in Regex.Matches(inputString,"\"([^\"]*)\""))
    Console.WriteLine(match.ToString());

//or in LINQ
var result = from Match match in Regex.Matches(line,"\"([^\"]*)\"") 
             select match.ToString();
原文链接:https://www.f2er.com/regex/357590.html

猜你在找的正则表达式相关文章