Most foods that contain carbohydrates can cause gas. By contrast, fats and proteins cause little gas. Foods that can cause gas include:
Sugars: The sugars that cause gas are raffinose, lactose, fructose, and sorbitol. Raffinose: Beans contain large amounts of this complex sugar. Smaller amounts are found in cabbage, brussels sprouts, broccoli, asparagus, other vegetables, and whole grains. Lactose: Lactose is the natural sugar in milk. It is also found in milk products, such as cheese and ice cream, and processed foods, such as bread, cereal, and salad dressing. Many people, particularly those of African, Native American, or Asian background, normally have low levels of lactase, the enzyme needed to digest lactose, after childhood. Moreover, as people age, their enzyme levels decrease. As a result, over time, people may experience increasing amounts of gas after eating food that contains lactose. Fructose: Fructose is naturally present in onions, artichokes, pears, and wheat. It is also used as a sweetener in some soft drinks and fruit drinks. Sorbitol: Sorbitol is a sugar found naturally in fruits such as apples, pears, peaches, and prunes. It is also used as an artificial sweetener in many dietetic foods and sugar-free candies and gums. Starches: Most starches, including potatoes, corn, pasta, and wheat, produce gas when they are broken down in the large intestine. Rice is the only starch that does not cause gas. Fiber: Many foods contain soluble and insoluble fiber. Soluble fiber dissolves easily in water and takes on a soft, gel-like texture in the intestines. Oat bran, beans, peas, and most fruits contain soluble fiber that is not broken down until it reaches the large intestine, where digestion causes gas.
Insoluble fiber, on the other hand, passes essentially unchanged through the intestines and produces little gas. Wheat bran and some vegetables contain this kind of fiber.
This answer is based on source information from the National Institute of Diabetes and Digestive and Kidney Diseases.