Pseudocode helped out alot here. Notice the use of reg expressions instead of iterating thru the string and pushing in a stack or such.