Velvet slugs (they aren't nudibranchs) are reef safe and they eat nothing but flatworms. However, that doesn't make them a good solution. Because the don't eat anything else, once the worm population gets low the slugs have trouble finding enough of them and eventually end up starving. Because they can never eat all the worms, the remainder almost always end up repopulating. Besides that, the slugs are very fragile and are easily sucked into pumps. IMO they're another animal that should never be collected for the hobby.
One of the most reliable ways to get rid of them is to practice strict nutrient control like you would for an algae problem (since in essence that's what you have), siphon out as many as you can as often as you can, and then finish off with a treatment of Flatworm Exit.