regex for list of names from string

regex for list of names from string

tests:

tests:

  1. 'Artist: Frank Gaard; Artist: Stuart Mead; Author: Frank Gaard; Author: Stuart Mead; Publisher: Le Dernier CRI, Marseille, France'
  2. 'Artist: Fusen'
  3. 'Artist: Tsujimura Shirō'
  4. 'Artist: Frank Gaard abc xyz; Artist: Stuart Mead; Author: Frank Gaard; Author: Stuart Mead; Publisher: Le Dernier CRI, Marseille, France'

output:

  1. ['Frank Gaard', 'Stuart Mead']
  2. ['Fusen']
  3. ['Stuart Mead']
  4. ['Frank Gaard abc xyz', 'Stuart Mead']

I want list of only artists name. so, far i have came up with r'Artist:\s*(.*)(?:;|$)' this regex but it only works with single artists(case 2 and 3). can somebody suggest general solution for all. I am trying to extract details between : and ;(if present).

In [10]: reg_str = 'Artist: Tsujimura Shirō xyz abc'

In [11]: re.findall(r'Artist:\s(.)(?:;|$)', reg_str) Out[11]: ['Tsujimura Shirō xyz abc']


Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

Top Python Development Companies | Hire Python Developers

After analyzing clients and market requirements, TopDevelopers has come up with the list of the best Python service providers. These top-rated Python developers are widely appreciated for their professionalism in handling diverse projects. When...

An Introduction to Regex in Python

An Introduction to Regex in Python

The Ultimate Guide to Regex (Regular Expressions) in Python

In this Python tutorial, we’ll learning about Regex (Regular Expressions) in Python. Learn how Python regex works, and be able to use the basic patterns and functions in Python’s regex module, re, for to analyze text strings.