views:

46

answers:

1

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=#800080>

should be

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

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

Thanks

+2  A: 

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.

alex