- Original Message -
From: "don" <[EMAIL PROTECTED]>
Newsgroups: comp.lang.python
To:
Sent: Thursday, May 11, 2006 7:39 PM
Subject: Reg Ex help
> I have a string from a clearcase cleartool ls command.
>
> /main/parallel_branch_1/release_branch_1.0/dbg_for_python/CHECKED
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 w
Edward Elliott wrote:
(snip)
>>don a écrit :
>>
>>>Also if there is a better way than using regex, please let me know.
>>
(snip)
>
> I wouldn't call these better (or worse) than regexes, but a slight variation
> on the above:
>
> marker = s.index('/CHECKEDOUT')
> branch = s [s.rindex('/', 0, mark
P.S.
This is how it works:
>>> s ="/main/parallel_branch_1/release_branch_1.0/dbg_for_python/CHECKEDOUT
>>> from /main/parallel_branch_1/release_branch_1.0/4"
>>> s
'/main/parallel_branch_1/release_branch_1.0/dbg_for_python/CHECKEDOUT
from /main/parallel_branch_1/release_branch_1.0/4'
>>> s.spli
If you have strings of all the CHECKEDOUT (is this from the lsco
command?), then the following might work for you:
>>> s ="/main/parallel_branch_1/release_branch_1.0/dbg_for_python/CHECKEDOUT
>>> from /main/parallel_branch_1/release_branch_1.0/4"
>>> s.split()[0].split('/')[-2]
'dbg_for_python'
>
Bruno Desthuilliers wrote:
> don a écrit :
>> 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('/')
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 - 'd
Hi don
> 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
Hi don,
there may well be a better way then regex, although I find them usefull
and use them a lot.
The way they work would be dependant on knowing some things. For
example, if the dir you are after is always 4
deep in the structure you could try something like...
path =
'/main/parallel_bran
> /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
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_fo
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 ther
12 matches
Mail list logo