【请问用JAVA如何从一篇英文文章中,提取出所有的单词?要考虑标点符号的干扰】
<p>问题:【请问用JAVA如何从一篇英文文章中,提取出所有的单词?要考虑标点符号的干扰】<p>答案:↓↓↓<p class="nav-title mt10" style="border-top:1px solid #ccc;padding-top: 10px;">代树武的回答:<div class="content-b">网友采纳 import java.util.StringTokenizer; public class $ { public static void main(String[] args) { String str = "I love you Lucy, You are my first!"; StringTokenizer st = new StringTokenizer(str, ", !");// 按逗号/空格/叹号分割,其他字符自行添加 while (st.hasMoreElements()) { System.out.println(st.nextElement()); } } }I love you Lucy You are my first
页:
[1]