Jump to content


Photo

missing character at end of match?


  • Please log in to reply
1 reply to this topic

#1 Braet

Braet
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 20 August 2006 - 06:14 AM

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:

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++;;}

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.

#2 effigy

effigy
  • Staff Alumni
  • Advanced Member
  • 3,600 posts
  • LocationIL

Posted 21 August 2006 - 02:41 PM

Please provide an example of input, and the desired output.

You are misusing a characters class. [^, which you pick up] Means any one character that is not a comma, space, w, h, i, c, y, o, u, p, or k.
Regexp | Unicode Article | Letter Database
/\A(e)?((1)?ff(?:(?:ig)?y)?|f(?:ig)?)\z/




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users