我想提取双引号内的那些单词。所以,如果内容是:
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();