开发者

Regex Parsing HTML [duplicate]

开发者 https://www.devze.com 2023-01-15 00:29 出处:网络
This question already has answers here: Closed 12 years ago. Possible Duplicate: RegEx match open tags except XHTML self-contained tags
This question already has answers here: Closed 12 years ago.

Possible Duplicate:

RegEx match open tags except XHTML self-contained tags

I would like to ensure that HTML attributes have quotes around them as is required by xhtml.

For example:

<BODY link=#0000ff vLink=#开发者_如何学Go800080>

should be

<BODY link="#0000ff" vLink="#800080">

I am looking for a Regex pattern that would handle this.

Thanks


Whilst not an exact duplicate, the basic answer is the same.

What you want is not regex, but a DOM parser.

Please specify your server side language. Or do you intend to do this with JavaScript? If so, there is not much point.

A suggestion too, if you are doing that to make it valid XHTML, then you should probably know the body element (and all the elements and attributes) are used in lowercase.

0

精彩评论

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