"Arun Tomar" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
On Sun, 2008-09-28 at 17:26 +0100, Alan Gauld wrote:
"Arun Tomar" <[EMAIL PROTECTED]> wrote
> I've been using shell scripting & using sed & pipes i've solved it,
> but with python, i need to practice more ;).
ok, i got it.
here is the code that needs to be included after code in the last mail ;)
sub1 = "(-.*)|(Tel:)|\(M\)|\(R\)"
new_reg = re.compile(sub1)
for n in range(len(new_array)):
mod_array.append(new_reg.sub('',new_array[n]))
Given your original data, this should work:
---------------------cut--------------------------------
data = '''\
Contact Candidate
Jyoti Soni - 0 Year(s) 0 Month(s)
MCA
Keyskills:
C , C + + , Java , JSP , Oracle , S / W Testing
B.Sc Pt.Ravishanker University,Raipur
MCA Pt.Ravishanker University,Raipur
Currently in: Pune
CTC(p.a): Not Disclosed
Modified: 27 Sep 2007
Tel: 09975610476(M)
Account Information
Account Information
Contact Candidate
Minal - 0 Year(s) 0 Month(s)
MCA
Keyskills:
c , c + + , java , ASP . NET , VB , Oracle , Dimploma in Web Designing
B.Sc Shivaji University , Maharasthra
MCA Shivaji University , Maharashtra
Currently in: Pune
CTC(p.a): INR 0 Lac(s) 5 Thousand
Modified: 27 Jan 2006
Last Active: 06 Sep 2007
Tel: 9890498376(M)
011 02162 250553(R)
Account Information
Account Information
'''
import re
record = re.compile(r'(?ms)Contact Candidate\s*\n(.*?) -.*?\nTel: (\d+)')
print record.findall(data)
----------------------cut------------------------
Output:
[('Jyoti Soni', '09975610476'), ('Minal', '9890498376')]
-Mark
_______________________________________________
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor