Reg Ex help

Paddy paddy3118 at netscape.net
Fri May 12 07:52:40 CEST 2006


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()
['/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]
'/main/parallel_branch_1/release_branch_1.0/dbg_for_python/CHECKEDOUT'
>>> s.split()[0].split('/')
['', 'main', 'parallel_branch_1', 'release_branch_1.0',
'dbg_for_python', 'CHECKEDOUT']
>>> s.split()[0].split('/')[-1]
'CHECKEDOUT'
>>> s.split()[0].split('/')[-2]
'dbg_for_python'
>>> 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.




More information about the Python-list mailing list