Hadith.4787 - Zurarah narrated from Abu Ja'far Imam Muhammad ibn Ali Al-Baqir عليه السلام:
"The divorce of a pregnant woman is a single divorce, and once she delivers what is in her womb, she is separated from him."
Allah سبحانه وتعالى, the Blessed and Exalted, said:
"And for those who are pregnant, their term is until they deliver their burden." (Surah At-Talaq 65:4)
Therefore, if a man divorces his wife and she delivers on the same day or the next, her waiting period (iddah) has ended, and it is permissible for her to marry.
However, her new husband cannot consummate the marriage until she becomes pure (completes her postpartum period).
A pregnant woman who is divorced must observe the shorter of the two waiting periods. If three months pass before she delivers, her waiting period is over, but she cannot remarry until she gives birth. However, if she delivers before the completion of three months, her waiting period ends immediately.
On the other hand, a pregnant woman whose husband has passed away must observe the longer of the two waiting periods. If she delivers before the completion of four months and ten days, her waiting period is not over until the full four months and ten days pass.
Conversely, if four months and ten days pass before she delivers, her waiting period does not end until she gives birth.