Reg Ex help

James Thiele jamesthiele.usenet at gmail.com
Thu May 11 14:04:34 EDT 2006


don wrote:
> 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.
>
> Thanks in advance,
> Don

Not regex, but does this do what you want?
>>> s = "/main/parallel_branch_1/release_branch_1.0/dbg_for_python/CHECKEDOUT"
>>> s = s + " from /main/parallel_branch_1/release_branch_1.0/4"
>>> s.split('/')[4]
'dbg_for_python'




More information about the Python-list mailing list