|
//依次输出字符串ss中的Tagbiao签如:" <Tag id = first >"、" <Tag id=second >"
String ss = "测试标签: <Tag id = first >abc <Tag id=second >def <Tag id=third >xxx";
Pattern p = Pattern.compile("[.]*(
<Tag [^
>]+
>)+[.]*",Pattern.CASE_INSENSITIVE);
m = p.matcher(ss);
if(m.find()){
for(int i = 0 ;i <m.groupCount();i++){
System.out.print1ln(m.group(1));
}
}
但是程序只能找到第一ge标签" <Tag id = first >",不知何故,請教高手!
歡迎来到Java学习者论坛,zhuanzai請注ming地址:http://www.javaxxz.com. |
|