How to split using comma before a specific string and maxsplit=1 using python regex? For Example here is a string: Speciality: "Aesthetic Medicine, Oncology" , Profession:"Physician (MD, DO, Resident)" I need to split this string at comma(,) right before "Profession".
something like this?
#!/usr/bin/python2
# -*- coding: utf-8 -*-
import re
txt = 'Speciality: "Aesthetic Medicine, Oncology" , Profession: "Physician (MD, DO, Resident)"'
a = re.match('^(.*?),\s+(Profession:)(.*?)$', txt)
if(a):
# print a.group(0)
first = a.group(1)
second = a.group(2)+a.group(3)
print first
print second
Output:
Speciality: "Aesthetic Medicine, Oncology"
Profession: "Physician (MD, DO, Resident)"
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments