编程语言
首页 > 编程语言> > java-从字符串中提取单词的正则表达式

java-从字符串中提取单词的正则表达式

作者:互联网

我想从Java字符串中提取所有单词.

该单词可以用任何欧洲语言书写,并且不包含空格,只能使用字母符号.

它可以包含连字符.

解决方法:

如果您不依赖于正则表达式,还可以查看BreakIterator,特别是getWordInstance()方法:

Word boundary analysis is used by search and replace functions, as well as within text editing applications that allow the user to select words with a double click. Word selection provides correct interpretation of punctuation marks within and following words. Characters that are not part of a word, such as symbols or punctuation marks, have word-breaks on both sides.

标签:text-segmentation,java,regex
来源: https://codeday.me/bug/20191024/1917076.html