Java - 根据引号和大写字母对字符串进行标记

Java - Tokenizing a string based on quotes and capital case

我想知道什么是标记化字符串的好方法,例如:

"'The president' of the United States is Barack Obama"

这样 returns:

{The president, of, the, United States, is, Barack Obama}

环顾四周后,我设法得到了以下正则表达式:

([A-Z][a-zA-Z0-9-]*)([\s][A-Z][a-zA-Z0-9-]*)+|'([^']*?)'|[^\s{.,:;”’()?!}]+

这似乎适合我的目的。

来源: