Well, this is not from experience, but from a technical viewpoint (there may be an easier way). Hacksaw out a section in the middle, then unscrew each end (you probably will need two wrenches to hold the fitting from moving around too much while you take out the old pipe). If what's left has a little movement to it, use a dielectric union on each end with a new copper piece inbetween. If those ends don't have any play so you can insert the pipe into the fittings, then it gets messier. Then you'd need a repair coupling to connect the two pieces of copper. A repair coupling doesn't have a stop in the middle, so you can slide it entirely over the pipe, meaning that you won't need to spread things apart to insert it into the pipe; just slide it over one end, get the other side lined up (after cleaning both the fitting and the ends), and slide the fitting so it is centered on the joint and solder it up.
Now, note that when unscrewing the old pipe, you might just create other leaks and this may be a good time to replace those pipes/fittings as well. It is only a matter of time...