user21037: I am trying to figure out an algorithm to extract the number of each piece that both black and white have from a PGN file. 
Right now I have all of the moves tokenized(i.e. c("e4", "d6", "Nc3", "f5", "exf5", "Bxf5", "Qh5", "g6"...), but I'm not sure where to proceed next. So far I know that identifying the "x" characters is necessary, but I am not sure what to do as the notation only identifies the capture square, and not what type of piece is captured.

user12873: You'd have some data structure, such as a 2-D 8x8 array, storing the current piece in each square of the board. Everytime you read a new move, update the array appropriately. Then, when you see a capture like "exf5", check what piece is stored in the "f5" square of the array.
You'll have to be careful with en passant captures. For example, in the case of 1.e4 c5 2.e5 d5 3.exd6, you should be checking the element in the array 1 row above (for d5). In order to detect when an en passant has occurred, see if a pawn captured on to an empty square. For example, 3.exd6 is White's e5-pawn capturing on to the empty d6-square, so it must be en passant.

21037: <p>I am trying to figure out an algorithm to extract the number of each piece that both black and white have from a PGN file. </p>

<p>Right now I have all of the moves tokenized(i.e. c("e4", "d6", "Nc3", "f5", "exf5", "Bxf5", "Qh5", "g6"...), but I'm not sure where to proceed next. So far I know that identifying the "x" characters is necessary, but I am not sure what to do as the notation only identifies the capture square, and not what type of piece is captured.</p>
 12873: <p>You'd have some data structure, such as a 2-D 8x8 array, storing the current piece in each square of the board. Everytime you read a new move, update the array appropriately. Then, when you see a capture like "exf5", check what piece is stored in the "f5" square of the array.</p>

<p>You'll have to be careful with en passant captures. For example, in the case of 1.e4 c5 2.e5 d5 3.exd6, you should be checking the element in the array 1 row above (for d5). In order to detect when an en passant has occurred, see if a pawn captured on to an empty square. For example, 3.exd6 is White's e5-pawn capturing on to the empty d6-square, so it must be en passant.</p>
