我有一個這樣的字符串..正則表達式和自定義標籤
<mytag>one line</mytag><mytag>second line with other tag <color=red>this words are red</color></mytag><youtube>GY7IU5FU</youtube>
我怎樣才能得到這個..
1 - (TAG) - mytag
1 - (DATA) - one line
2 - (TAG) - mytag
2 - (DATA) - second line with other tag <color=red>this words is red</color>
3 - (TAG) - youtube
3 - (DATA) - GY7IU5FU
林與此嘗試,但不起作用
<(.*).*?<\/?\1>
使用html解析器 – tenub
爲什麼要使用正則表達式?這是html。 – mikea
或者只是在您的正則表達式中使用捕獲組。快速谷歌搜索'java正則表達式捕獲組'揭示[this](http://www.javamex.com/tutorials/regular_expressions/capturing_groups.shtml#.Us1ymGRDsrg) – tenub