Each pair of leggings comes with a toggle, you can thread this on the drawstring and it will stop it coming out in the wash. You can also tie the drawstring in a tight knot before washing.
Using a laundry bag helps too, and also keeps your leggings safe from abrasion damage in the wash. If it does come out, use a large paperclip or safety pin, attach to one end of the drawstring and use it to help thread it through the waistband.