Reg Ex help

Bruno Desthuilliers bdesth.quelquechose at free.quelquepart.fr
Fri May 12 02:28:33 CEST 2006


don a écrit :
> I have a string  from a clearcase cleartool ls command.
> 
> /main/parallel_branch_1/release_branch_1.0/dbg_for_python/CHECKEDOUT
> from /main/parallel_branch_1/release_branch_1.0/4
> 
> I want to write a regex that gives me the branch the file was
> checkedout on ,in this case - 'dbg_for_python'
> 
> Also if there is a better way than using regex, please let me know.

s ="/main/parallel_branch_1/release_branch_1.0/dbg_for_python/CHECKEDOUT
  from /main/parallel_branch_1/release_branch_1.0/4"
parts = s.replace(' ', '/').strip('/').split('/')
branch = parts[parts.index('CHECKEDOUT') - 1]



More information about the Python-list mailing list