gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-02 07:58:12 24 4
gpt4 key购买 nike

我想从 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.

关于java - 从字符串中提取单词的正则表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3139382/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com