0

I want to get 2014, December from following value

<tr>
<th rowspan="2" scope="row">Launch</th>
<td class="ttl"><a href=# onClick="helpW('h_year.htm');">Announced</a></td>
<td class="nfo">2014, December</td>
</tr>

And I used the following code to get that without any success

preg_match_all("/Announced<\/a><\/td><td class=\"nfo\">(.*?)<\/td>/m", $input_lines, $output_array);

I tried /./s in place of x but no luck. I need your advice.

PS: I cannot use DOM parser because I had already many patterns ready to extract string as per my need using regex.

EDIT: This now also solved my issue

preg_match_all("/(Announced<\/a><\/td>).*?(<td class=\"nfo\">)(.*?)<\/td>/s", $input_lines, $output_array);
LuckyCoder
  • 520
  • 8
  • 27

1 Answers1

2

You forget to add a \n character inbetween in your regex.

preg_match_all("~Announced<\/a><\/td>\n<td class=\"nfo\">(.*?)<\/td>~m", $input_lines, $output_array);
                                      ^
                                      |

DEMO

Avinash Raj
  • 172,303
  • 28
  • 230
  • 274