0
Stringを1つのタグとして扱い、すべてを一緒に抽出するコードがあります。この場合、"abc </a > <a> def" "です。 2つの文字列 "abc"と "def"を得るために、タグから別々に抽出する方法?これらは、通常のranguages使用することはできませんので正規表現ではありませんので、タグの内容を複数回抽出する方法は?
public static void main(String[] args) throws Exception {
Ex.findInTags("<a>((.*))</a>", "<a>abc</a> <a>def</a>");
}
public static void findInTags(String a, String b) {
Pattern pattern = Pattern.compile(a);
Matcher matcher = pattern.matcher(b);
if (matcher.find()) {
System.out.println(matcher.group(1));
}
}
私はいくつかの疑問があるが、おそらく重複しているので、VotingToCloseではない:http://stackoverflow.com/a/1732454/598289 – SJuan76
XHTML自己完結型タグを除いた[RegEx match open tags]の可能な複製http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags) – baudsp