Reg Ex help
Edward Elliott
nobody at 127.0.0.1
Fri May 12 05:02:03 EDT 2006
bruno at modulix wrote:
> parts = s.replace(' ', '/').strip('/').split('/')
> branch = parts[parts.index('CHECKEDOUT') - 1]
>
> Edward Elliott wrote:
>>
>> marker = s.index('/CHECKEDOUT')
>> branch = s [s.rindex('/', 0, marker) + 1 : marker]
>
> Much cleaner than mine. I shouldn't try to code when it's time to bed !-)
Not terribly readable though, hard to tell what the magic slice indexes
mean. Yours is easier to follow. I think I'd just use a regex though.
--
Edward Elliott
UC Berkeley School of Law (Boalt Hall)
complangpython at eddeye dot net
More information about the Python-list
mailing list