I'm reading a list by line and using regex in c# to capture the fields:
fed line 1: Type: eBook Year: 1990 Title: This is ebook 1 ISBN:15465452 Pages: 100 Authors: Cendric, Paul
fed line 2: Type: Movie Year: 2016 Title: This is movie 1 Authors: Pepe Giron ; Yamasaki Suzuki Length: 4500 Media Type: DVD
string pattern = @"(?:(Type: )(?<type>\w+)) *(?:(Year: )(?<year>\d{4})) *(?:(Title: )(?<title>[^ISBN]*))(?:(ISBN:) *(?<ISBN>\d*))* *(?:(Pages: )(?<pages>\d*))* *(?:(Authors: )(?<author1>[\w ,]*)) *;* *(?<author2>[\w ,]*) *(?:(Length: )(?<length>\d*))* *(?:Media Type: )*(?<discType>[\w ,]*)";
MatchCollection matches = Regex.Matches(line, pattern);
If the line fed has "Length: " I want to stop capturing the surname of the Author excluding the word Length.
If I use (?:(Length: )(?<length>\d*))*
Length is added to the surname of the second author for match.Groups["author2"].Value
. If I use (?:(Length: )(?<length>\d*))+
I get no matches for the first line.
Can you please give me guidance. Thank you, Sergio