how to prevent runners diarrhea

At least one day before running, limit or avoid high-fiber and gas-producing foods, such as beans, bran, fruit and salad. If you run every day, experiment to find a tolerable level of fiber. Otherwise, simply eat those foods after you run.
At least one day before running, limit or avoid sweeteners called sugar alcohols (isomalt, sorbitol, others) — most often found in sugar-free candies, gum and ice cream.

For three to six hours before running, limit or avoid caffeine and high-fat foods.
For at least two hours before running, don’t eat anything at all.
Before, during and after running, drink plenty of fluids. Dehydration can lead to diarrhea. Avoid warm liquids, however, which can speed food through the digestive tract.
While running, use caution with energy gels and energy bars. In some people, these products can contribute to diarrhea. And especially avoid introducing a new gel or bar on race day.
If you’re lactose intolerant, switch to lactose-reduced or lactose-free milk and milk products.
Avoid nonsteroidal anti-inflammatory drugs (NSAIDs) such as ibuprofen (Advil, Motrin IB, others) or naproxen (Aleve). Both have been shown to increase the incidence of gastrointestinal complaints.