开发者

Regex: simple Java Regex Question

开发者 https://www.devze.com 2022-12-27 05:33 出处:网络
My XML is mal-formated fortag. Specifically, I want everytag that is not ended withto be corrected. How do I match开发者_如何学Go such pattern and using ReplaceAll to do that?

My XML is mal-formated for tag. Specifically, I want every tag that is not ended with to be corrected. How do I match开发者_如何学Go such pattern and using ReplaceAll to do that?

Pattern r = "<img.*?[^/]>" // sth like that?


You forgot a semicolon :)

No seriously, use a (X)HTML parser/cleanup API which can convert tagsoup (HTML) to XHTML. Under each JTidy can do that in a single call:

new Tidy().parseDOM(inputStream, outputStream);

Regex is simply not well suited for this job.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号