regex, split and ()
Steve Lamb
grey at despair.rpglink.com
Wed Dec 27 12:22:30 EST 2000
On 27 Dec 2000 17:14:34 GMT, Jacek Pop³awski <jp at ulgo.koti.com.pl> wrote:
>>>> w=re.compile(r'(<[^<>]*(".*")?>)')
>>>> s="<html> one <br> two <img src=\"<blah\"> three </html>"
>>>> w.split(s)
>['', '<html>', None, ' one ', '<br>', None, ' two ', '<img src="<blah">',
>'"<blah"', ' three ', '</html>', None, '']
>works good, but why it double everything? probably becouse I used second (),
>how to fix it?
Use ?: in the parens you don't want to retain.
--
Steve C. Lamb | I'm your priest, I'm your shrink, I'm your
ICQ: 5107343 | main connection to the switchboard of souls.
-------------------------------+---------------------------------------------
More information about the Python-list
mailing list