Jump to content


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


missing character at end of match?

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)
if ($row % 2)
{echo "<TR><TD>".$loot[1][$i2]."</TD><TD>".$loot[2][$i2]."</TD></TR>";}
{echo "<TR><TD CLASS=\"one\">".$loot[1][$i2]."</TD><TD CLASS=\"one\">".$loot[2][$i2]."</TD></TR>";}

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.

Share this post

Link to post
Share on other sites
Please provide an example of input, and the desired output.

You are misusing a characters class. [tt][^, which you pick up][/tt] Means any one character that is not a comma, space, w, h, i, c, y, o, u, p, or k.

Share this post

Link to post
Share on other sites


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.