My rear gear cable snapped at the shifter. Thanks to these posts and a mooch around some other forums I got it sorted quickly.
The key is getting the shifter into the highest gear (ie smallest cog). Once you've done that the old cable should pop out easily and the new one just threads through from the outside of the shifter. You will need to squeeze the brake lever to get the
cable in or out.
As far as I can tell in normal operation the derailleur spring pulls on the cable which helps pull the shifter to a higher gear when you press the upshift lever (the small black one). When the cable is broken, and the spring not pulling, the upshift lever won't get you to the highest gear. If you can grab the frayed cable with a pair of pliers you can pull on it whilst operating the upshift and then, hopefully, get the shift to the highest gear.
As I say once you have the shifter in the highest gear getting the cable out and back in should be easy.