Thanks. Any easier way to do a 'replace' then using start(), end(), and slicing operations? I'm currently doing it manually.
On 9/24/07, Miles <[EMAIL PROTECTED]> wrote: > > On 9/24/07, Robert Dailey <[EMAIL PROTECTED]> wrote: > > Hi, > > > > I'm attempting to create a regular expression that removes redundancy in > > empty XML elements. For example: > > > > <root></root> > > > > The regular expression would convert the XML above into: > > > > <root/> > > If you can guarantee that the XML is well-formed, then this should work: > > pattern = r'<([^/>][^>]*(?<!/))></[^>]+>' > replace = r'<\1/>' > > -Miles >
-- http://mail.python.org/mailman/listinfo/python-list