-1

Websiste contains some codes like below..

</span></td>
    <td width="1%" align="right" nowrap="nowrap" class="small inner" >190 MB</td>
    <td width="1%" align="center" nowrap="nowrap" class="small inner" >15</td>

I need to get 190MB

I tried below code..tried /s , /m nothing works..

preg_match_all('/<\/td>
    <td width="1%" align="right" nowrap="nowrap" class="small inner" >(.*?)<\/td>/m',$lol,$cooler);

2 Answers2

2

Ew, parsing HTML with regex. Never a good idea.

Since there don't appear to be any handy identifiers that a parser could help you hook into, why not just preg_match("/\d+\s*[KMG]B/,$lol,$match); echo $match[0];`? Keep it as simple as possible.

Niet the Dark Absol
  • 311,322
  • 76
  • 447
  • 566
1
$lol = '</span></td>
<td width="1%" align="right" nowrap="nowrap" class="small inner" >190 MB</td>
<td width="1%" align="center" nowrap="nowrap" class="small inner" >15</td>';    

preg_match_all('/(?<=\<\/span\>\<\/td\>)[\n]?.*((?<=\>).+(?=\<))/', $lol, $cooler);

echo $cooler[1][0]; //Outputs "190 MB"

http://regex101.com/r/jY1pY9/1

SierraOscar
  • 17,307
  • 5
  • 38
  • 67