【发布时间】:2019-02-08 11:40:58
【问题描述】:
我正在尝试从文本中提取单词。我的文字如下所示:
String text = "This is my text and it contains a url: http://www.google.com";
String[] words = text.split("\\W+");
这里的问题是这样的 url 被分解为 http www google com 这样的词,它对我来说变得毫无用处。
我想要的是这样的数组:
This
is
my
text
and
it
contains
a
url
http://www.google.com
有什么想法/建议吗?
【问题讨论】: