有趣的事实 。A
word是语音或写作的一个独特元素,形成一个句子,通常在两边都带有空格。
w匹配(任何
letter,
number或
underscore)
不清楚您要问的是什么,而没有更好地解释您要完成的任务。
如果要包含一个单词匹配
letters和撇号
'有 更多 比
3字符..
List<String> words = new ArrayList<String>();String s = "I want to have alot of money's when I am older.";Pattern p = Pattern.compile("[a-zA-Z']{4,}");Matcher m = p.matcher(s);while (m.find()) { words.add(m.group());}System.out.println(words);// [want, have, alot, money's, when, older]注意 :这匹配包含多个
3字符的单词,如果您还想匹配包含
3(
foo)或更多字符的单词,则可以使用以下内容。
Pattern p = Pattern.compile("[a-zA-Z']{3,}");


