Regular Expressions: Can't quite figure this problem out
semanticist at gmail.com
Tue Sep 25 03:27:19 CEST 2007
On 9/24/07, Robert Dailey <rcdailey at gmail.com> wrote:
> I'm attempting to create a regular expression that removes redundancy in
> empty XML elements. For example:
> The regular expression would convert the XML above into:
If you can guarantee that the XML is well-formed, then this should work:
pattern = r'<([^/>][^>]*(?<!/))></[^>]+>'
replace = r'<\1/>'
More information about the Python-list