Java:获取与Regular表达式匹配的每个字符串的数组
我将如何解析这样的文件:
Item costs $15 and is made up of --Metal-- Item costs $64 and is made up of --Plastic--
我可以
Pattern p = Pattern.compile(regex); Matcher m = p.matcher(input); String result = m.group();
但是我怎么能得到每一个结果呢?
Pattern p = Pattern.compile(regex); Matcher m = p.matcher(input); List matches = new ArrayList (); while(m.find()){ matches.add(m.group()); }