I have 3 strings from wich I want to extract the movie title, if posible in one RegularExpression
<title>Airplane! (1980)</title>
<title>"24" (2001)</title>
<title>"Agents of S.H.I.E.L.D." The Magical Place (2014)</title>
My best shot so far is this one:
<title>(")?(.*?)(")?.*?\((\d{4})\).*?</title>
Works fine for "Agents of S.H.I.E.L.D." and "24" but not for "Airplane!".
What am I doing wrong?
Even though it might not be clear the regular expression are called within a C# program, and I'm using RegEx
RE for start-of-line => opening tag => optional "
=> read until "
or (nnnn)
titles = System.Net.WebUtility.HtmlDecode(titles);
foreach (Match match in Regex.Matches(titles,
@"^\s*<title>\s*\""*(.*?)(\""|\(\d{4}\))", RegexOptions.Multiline | RegexOptions.IgnoreCase))
{
if (match.Success)
{
string name = match.Groups[1].Value;
}
}