Before you can do any home plumbing repair or maintenance, you'll have to know the size of the pipe that is needed. Don't be surprised if you have to make a few trips to your plumbing supply store because you didn't get the pipe size right. Trial and error is a natural part of sizing pipes, but knowing what to look for the first time may save you a few gallons of gas.
Cut open the pipe you're replacing. Measure it from inside with a tape measure, since all pipes are sized according to their inside diameters. Measure the pipe itself, not the fitting.
Round off the measurement of the inside diameter to the nearest 1/8 inch. This provides the "nominal dimension" of the pipe -- the dimension you need when you go to buy the replacement pipe. The difference between the diameter measurement and the nominal measurement can be based on the thickness of the pipe walls.
Wrap a string around a piece of pipe if you cannot measure the inside diameter. Unwrap the string and use a tape measure to find its length. This gives you the pipe's outside diameter. Use this measurement and a dimensional chart to find the pipe's nominal dimension.
Take into account the distance between pipe fittings, as well as the distance of the pipe engaged inside the fittings. Measure first from face to face -- the part of the pipe visible outside the fittings. Next, measure the depths of the sockets into which the pipe is fitted. Pipes are required to fit fully into the sockets, but the socket depth varies from one pipe size to another, as well as from one pipe material to another.