public static void main(String[] args) {
String source="
";
StringBuilder result=new StringBuilder();
System.out.println("=======开始匹配文字内容========");
String patternStrs="(
)";
Pattern pattern=Pattern.compile(patternStrs);
Matcher matcher=pattern.matcher(source);
while(matcher.find()){
result.append(matcher.group(2)+"\n");
}
System.out.println(result.toString());
System.out.println("=======开始匹配name属性值========");
String patternName="(
)";
pattern=Pattern.compile(patternName);
matcher=pattern.matcher(source);
result=result.delete(0, result.length());
while(matcher.find()){
result.append(matcher.group(2)+"\n");
}
System.out.println(result.toString());
} $txt="< div id=\"etcTrans\" class=\"trans-container tab-content\">
preg_match_all("/<\s*div\s+id=\"etcTrans\"\s+(.*)>(.*)<\/div\s*>/",$txt,$match);
preg_match_all("/<\s*ul\s*><\s*li\s*>(.*)<\/li\s*><\/ul\s*>/",$match[0][0],$match2);