Andrew Nodermann
Andrew Nodermann

Reputation: 680

Regex extract list of names

I have almost complete regex, but does not capture "director Nicolas Winding Ref", appreciate any help

: Actor Keanu Reeves attends

: Actors Keanu Reeves, Alessandro Nivola, Christina Hendricks, Bella Heathcote, Elle Fanning and director Nicolas Winding Refn attend

: Actresses Bella Heathcote, Elle Fanning and Christina Hendricks attend

regex:

: {1}([A-Za-z\. \-,]*?) (?!and)[a-z]

https://www.debuggex.com/r/i8yEYRXVhlf9TzQL

Upvotes: 0

Views: 67

Answers (1)

Avinash Raj
Avinash Raj

Reputation: 174706

Think you want something like this,

: ([A-Z][a-z]*(?: [A-Z][a-z]*)*(?:, [A-Z][a-z]*(?: [A-Z][a-z]*)*)*)(?: and(?: \w+)? ([A-Z][a-z]*(?: [A-Z][a-z]*)*))?

DEMO

Upvotes: 1

Related Questions