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, marker) + 1 :
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
: comp.lang.python
To: python-list@python.org
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/CHECKEDOUT
from /main/parallel_branch_1/release_branch_1.0/4
I want to write
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
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 -
/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
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 =
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'
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 -
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('/')
branch
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'
- Paddy.
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.split()
12 matches
Mail list logo