There are 2 types of lines:

"August 1, 2011 <b> Manchester City </ b> Swansea City <font color = blue> 4: 0 </ font>";

"August 21, 2011 Bolton Wanderers <b> Manchester City </ b> <font color = blue> 2: 3 </ font>";

Those. in one, the name of the first team in <b> </ b>, in the other - the second team. Here is the page itself:

See the source code. With the help of preg_match_all from each line you need to cut the date xx.xx.xxxx name of the first command and the second (together with the <b></b> , if present) and the score "4: 0". Already waved. Help.

 preg_match_all('#([0-9]{2}\.[0-9]{2}\.[0-9]{4})((?:<b>)?.*(?:\s{2}<\/b>\s*)?)((?:<b>)?.*(?:\s{2}<\/b>\s*)?)<font.*>#', $games, $game); 

I tried something like that, but not out because of the gaps ..

    1 answer 1

     $date= "(?P<date>\d{1,2}\.\d{1,2}\.\d{2,4})"; $com1="(\<b\>(?P<com1>.*?)\<\/b\>|(?P<com1a>.*?)(?=<))"; $com2= str_replace("1", "2", $com1); $count="<font[^>]*>(?P<count>.*?)<\/font>"; $str=" 15.08.2011 <b>Манчестер Сити </b> Суонси Сити <font color=blue>4:0 </font>"; $str2=" 21.08.2011 Болтон Уондерерс <b>Манчестер Сити </b> <font color=blue>2:3 </font>"; $re="/".$date."\\s+".$com1."\\s*".$com2.".*?".$count."/iu"; function show($arr) { echo $arr["date"][0]."<br/>".($arr["com1"][0]?$arr["com1"][0] : $arr["com1a"][0])."<br/>". ($arr["com2"][0]?$arr["com2"][0] : $arr["com2a"][0])."<br/>".$arr["count"][0]."<br/>"; }; preg_match_all($re, $str, $arr); show($arr); echo "<br/>"; preg_match_all($re, $str2, $arr); show($arr); 

    The result will be returned to the named groups. In this case, the command 1 will be either in com1 or in com1a. A similar situation with the second team. In the PSP, you cannot use two groups with the same name, therefore such a restriction.
    Result of work:

     15.08.2011 Манчестер Сити Суонси Сити 4:0 21.08.2011 Болтон Уондерерс Манчестер Сити 2:3 

    upd Increased the visibility of the result.