java string截取两个字符串之间的值
java string截取两个字符串之间的值
import java.util.regex.Matcher; import java.util.regex.Pattern; public class GetTag { public static void main(String[] args){ String str = "abc<icon>def</icon>deftfh<icon>a</icon>"; Pattern p=Pattern.compile("<icon>(\\w+)</icon>"); Matcher m=p.matcher(str); while(m.find()){ System.out.println(m.group(1)); } } }