Carbohydrate rich foods are often the worst offenders. Most gas
results from sugars and starches. Colonies of harmless bacteria
in the colon eat the carbohydrates, giving off the by-products
hydrogen, carbon dioxide and methane in some people. A special
type of sugar called raffinose is found in beans and in smaller
amounts in some vegetables and grains. The human body lacks the
enzyme called alpha-galactosidase to digest this sugar and so
bacteria in the colon have a feast.
Avoid the gas forming foods and then add back those that are tolerated
well. People vary in their reactions to foods, so don't assume
that what is "gassy" for someone else will be "gassy" for you.