3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $lines = [ '"#InstaFamous: How to Become Famous on Instagram" (2013) 2013-????', '"#1 Single" (2006) {The Rules of Dating (#1.3)} 2006', '"WWE Velocity" (2002) {(2005-11-05)} 2005', '"#Follow" (2011) 2011-????', '"!Next?" (1994) 1994-1995', ]; foreach ($lines as $key => $line) { preg_match('~ ("?(?<showTitle>.*?)"?) \s \((?<showDate>\d{4})\) ([^{}\d]+) ( ({\(.*?\)}) | ({ (?<partTitle>.*?)? (\( \#(?<season>\d+)\.(?<episode>\d+) \))? }) )? \s? (?<partDate>([\d\-\?]+)) ~misx', $line, $data); foreach($data as $key => $value) if(is_int($key)) unset($data[$key]); var_dump($line, $data); }
Output for 5.4.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
string(66) ""#InstaFamous: How to Become Famous on Instagram" (2013) 2013-????" array(6) { ["showTitle"]=> string(47) "#InstaFamous: How to Become Famous on Instagram" ["showDate"]=> string(4) "2013" ["partTitle"]=> string(0) "" ["season"]=> string(0) "" ["episode"]=> string(0) "" ["partDate"]=> string(9) "2013-????" } string(52) ""#1 Single" (2006) {The Rules of Dating (#1.3)} 2006" array(6) { ["showTitle"]=> string(9) "#1 Single" ["showDate"]=> string(4) "2006" ["partTitle"]=> string(20) "The Rules of Dating " ["season"]=> string(1) "1" ["episode"]=> string(1) "3" ["partDate"]=> string(4) "2006" } string(41) ""WWE Velocity" (2002) {(2005-11-05)} 2005" array(6) { ["showTitle"]=> string(12) "WWE Velocity" ["showDate"]=> string(4) "2002" ["partTitle"]=> string(0) "" ["season"]=> string(0) "" ["episode"]=> string(0) "" ["partDate"]=> string(4) "2005" } string(26) ""#Follow" (2011) 2011-????" array(6) { ["showTitle"]=> string(7) "#Follow" ["showDate"]=> string(4) "2011" ["partTitle"]=> string(0) "" ["season"]=> string(0) "" ["episode"]=> string(0) "" ["partDate"]=> string(9) "2011-????" } string(25) ""!Next?" (1994) 1994-1995" array(6) { ["showTitle"]=> string(6) "!Next?" ["showDate"]=> string(4) "1994" ["partTitle"]=> string(0) "" ["season"]=> string(0) "" ["episode"]=> string(0) "" ["partDate"]=> string(9) "1994-1995" }
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/eR05E on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/eR05E on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/eR05E on line 3
Process exited with code 255.