正则表达式从字符串中提取引号中的单词?

kra*_*ash 2 java regex

因此,我希望从字符串中提取引号(")中的单词(或短语).
例如,假设主字符串是:
The quick brown fox "jumped over" the "lazy" dog
我希望能够提取并存储变量中的单词/短语在引号中,即
jumped over
lazy
应该存储在变量中.输入字符串只引用引号(没有单引号).
我尝试了以下(粗略)代码:

Pattern p = Pattern.compile("\\s\"(.*?)\"\\s");
Matcher m = p.matcher(<String>);
Variable.add(m.group(1));
Run Code Online (Sandbox Code Playgroud)

无论我输入什么,它都会抛出IllegalStateException.我感觉我的正则表达式无法正常工作.任何帮助表示赞赏.

Aub*_*bin 5

你的代码缺少一些if( m.matches())m.find()哪些工作......

这段代码:

String in = "The quick brown fox \"jumped over\" the \"lazy\" dog";
Pattern p = Pattern.compile( "\"([^\"]*)\"" );
Matcher m = p.matcher( in );
while( m.find()) {
   System.err.println( m.group( 1 ));
}
Run Code Online (Sandbox Code Playgroud)

输出:

jumped over
lazy
Run Code Online (Sandbox Code Playgroud)