I want to get the text in quotations after the occurrence of the pattern "name".
A sample string is:
info = "name: joe", "name: jerry", "name: kate"
Here is what I'm doing:
import re
string = 'info = "name: joe", "name: jerry", "name: kate"'
array = re.findall(r'"(.*?)"', string)
for x in array:
x = x.replace(" ","") #remove spaces because there might be space before colon occasionally
print(x.split("name:")[1])
The output prints:
joe
jerry
kate
I am just wondering if there is any easier way to do this and return the same output than what I did.