[Tutor] Help with multiple substitution
vankayala sailakshman
sailakshman9 at hotmail.com
Fri Jul 24 17:22:15 CEST 2009
Hi All,
Help needed to write a python script!!!
Iam a python newbie and my problem
is doing multiple substitution in a text file using Python regular
expressions. Here is my following data, I need to chop of all the
extensions that are given in the following list and replace with
empty string in their position. I have tried to solve for the past two days but couldn't succeed. Any help would be appreciated. Thanks
in advance.Sai....
for example, for “abc22035.pr.1”
i need to get “abc22035”
chopset = ['.p', '.pr', '.prp',
'.prpp', '.ps', '.psp', '.pspp', '.s', '.p.1','.pr.1', '.prp.1',
'.prpp.1', '.ps.1', '.psp.1','.pspp.1', '.s.1']
abc22035.pr
abc22035.pr.1 abc21409
.ps.1
abc21409.pr.1 abc21154
abc21154.pr.1 abc07584_EAOEA
abc07584_EAOEA.ps.1 abc20991.pr
abc20991.ps. abc21156
abc21156.ps.1 abc21409
abc21409.ps. abc21156
abc21156.pr.1 abc21408
abc21408.ps.1 abc21370.psp
abc21370.pr.1 abc21370
abc21370.ps.1 abc22036
abc22036.pr.1 abc21154
abc21154.ps.1 abc22036.prpp
abc22036.ps.1 abc20991
abc20991.pr.1 abc21772
abc21772.pr.1 abc21408
abc21408.pr.1 abc07584_EAOEA
abc07584_EAOEA.pr.1 abc21065
_________________________________________________________________
Missed any of the IPL matches ? Catch a recap of all the action on MSN Videos
http://msnvideos.in/iplt20/msnvideoplayer.aspx
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090724/2e54074b/attachment-0001.htm>
More information about the Tutor
mailing list