Jump to content

missing character at end of match?


Braet

Recommended Posts

have a preg match that is working as needed, printing what I need it to as well, but for some reason each printed line is missing the very last character.  I've tried adjusting my regex but have only successfully broken it many ways:

[code]preg_match_all("/The (.+?) drops (.+?)[^, which you pick up]\./", $data, $loot);
$totLoots = (count($loot[1]) -1);
$i2 = 0;
while ($i2 <= $totLoots)
{$row=$i2+1;
if ($row % 2)
{echo "<TR><TD>".$loot[1][$i2]."</TD><TD>".$loot[2][$i2]."</TD></TR>";}
else
{echo "<TR><TD CLASS=\"one\">".$loot[1][$i2]."</TD><TD CLASS=\"one\">".$loot[2][$i2]."</TD></TR>";}
$i2++;;}[/code]

it should return a name, and an item when there is a period after the item - and ignore it if it then goes on to say ', which you pick up' prior to the period.  It is returning the information, just cutting off the very last letter of the item.

tia in advance.
Link to comment
https://forums.phpfreaks.com/topic/18078-missing-character-at-end-of-match/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.