Re: Reg Ex help

2006-05-12 Thread Anthra Norell
- 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

Re: Reg Ex help

2006-05-12 Thread Edward Elliott
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

Re: Reg Ex help

2006-05-12 Thread bruno at modulix
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

Re: Reg Ex help

2006-05-11 Thread 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.spli

Re: Reg Ex help

2006-05-11 Thread Paddy
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' >

Re: Reg Ex help

2006-05-11 Thread Edward Elliott
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('/')

Re: Reg Ex help

2006-05-11 Thread Bruno Desthuilliers
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

Re: Reg Ex help

2006-05-11 Thread Mirco Wahab
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

Re: Reg Ex help

2006-05-11 Thread Aaron Barclay
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

Re: Reg Ex help

2006-05-11 Thread Tim Chase
> /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

Re: Reg Ex help

2006-05-11 Thread James Thiele
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

Reg Ex help

2006-05-11 Thread 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' Also if ther