0

I want to pick multiple sub-strings matches with the RegExp pattern, but can not match with the multiple occurrence. I'm trying the following code,

Code

a ="Full team names -they are [names { John Mark }] , [names {Kumar Shinos123 }] ,  [names { Dona Carlos}] and  [names {Jordan/mit/p1_s2 Powel}] "

pattern = re.compile(r"names+\s{(\W.+)\}")
match = pattern.findall(a)
print((match))

Current output

[' John Mark }] , [names {Kumar Shinos123 }] ,  [names { Dona Carlos}] and  [names {Jordan/mit/p1_s2 Powel']

Actually, I want to pick each matching in between [names { and }]. For the first matching John Mark, second matching Kumar Shinos123 and so on.

My expected output

[' John Mark ', 'Kumar Shinos123',  ' Dona Carlos', 'Jordan/mit/p1_s2 Powel']

Your assistance is highly appreciated. Thank you.

Wiktor Stribiżew
  • 484,719
  • 26
  • 302
  • 397
Z Islam
  • 21
  • 6

0 Answers0