usr bin python coding utf-8 import re open PB_Backup vcf contents read

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
#!/usr/bin/python
# -*- coding: utf-8 -*-
import re
f = open('PB_Backup.vcf')
contents = f.read()
f.close()
def replace_phones(matchobj):
return matchobj.group('begin')+matchobj.group('number')[1:]+matchobj.group('end')
regex = ur'(?P<begin>TEL.+:)(?P<number>\d{11})(?P<end>.+)'
output = re.sub(regex, replace_phones, contents)
f = open('PB_Result.vcf', 'wb')
f.write(output)
f.close()