lundi 21 décembre 2020

parse: match in the middle part of a string

I am using the parse package to extract some information from strings. I have a pattern like:

pattern = compile("hello {}")
s = "I am Jack, hello Mike, hello Tom! nice to meet you."
pattern.parse(s)

I want to extract 'Mike', 'Tom' out of s, no matter what's before and after the matched patterns in the string. How should I modify my pattern?

Aucun commentaire:

Enregistrer un commentaire