Pregnant or nursing mothers are exempt from fasting on the four fasts of Som Gedaliah, the 10th of Tebeth, Ta'anith Esther and the 17th of Tammuz. For this purpose, a woman is considered to be pregnant only after the third month. A nursing mother is one who actually nurses her child but not like the opinion which says she is considered to be a nursing mother for a full 24 months after giving birth, even if she is not actually nursing.
A woman who is very weak from giving birth, is considered to be a Holah (one who is ill), and should not fast, even if is not considered dangerous. It goes without saying that if the doctors tell her not to fast, even at the beginning stages of her pregnancy, she should not fast.
If a woman who is pregnant or nursing feels that she would like to fast, she is permitted to do so. However, if she starts to feel any difficulty, she must stop fasting immediately, and is actually forbidden from continuing to fast. Unless a person is told by doctors not to fast, or knows for sure that it would be harmful, it is customary for one who is exempt from fasting, to start fasting but break the fast if one feels any difficulty.
(See Hilkhoth Hagim, Maamar Mordekhai [Eliyahu] 24:35, 26, 38)
Who is exempt on a Ta'anith fast day, preganant and nursing on a fast day