fork download
  1. import re
  2. pattern = r"((\d+)\. .*?)[^\w!?.…]*(?=\d+\. |\Z)"
  3. text = "1. Shares of Paras Defence and Space Technologies gained 2.85 times. 2. The company, engaged in manufacturing and testing of defence and space engineering products. \"3. Its stock ended at Rs 499 versus issue price of Rs 175 per share. 42. On July 23, Zomato NSE 0.00 % Ltd. listed on the Indian stock exchanges. 43. That was exactly a week after the food-delivery and restaurant discovery platform's initial public offering went live. 4. Paras Defence’s IPO, which closed on September 23, had generated bids worth Rs 38,021 crore. 5. It surpassed the previous record of Salasar Technologies’ IPO. 14. NBFCs are betting big time on the IPO. 6. Paras Defence is one of the few players having an edge in defence deals."
  4. result = []
  5. idx = 1
  6. for sent, num in re.findall(pattern, text, re.S):
  7. if int(num) == idx:
  8. result.append(sent)
  9. idx += 1
  10.  
  11.  
  12. print("\n".join(result))
Success #stdin #stdout 0.03s 9540KB
stdin
Standard input is empty
stdout
1. Shares of Paras Defence and Space Technologies gained 2.85 times.
2. The company, engaged in manufacturing and testing of defence and space engineering products.
3. Its stock ended at Rs 499 versus issue price of Rs 175 per share.
4. Paras Defence’s IPO, which closed on September 23, had generated bids worth Rs 38,021 crore.
5. It surpassed the previous record of Salasar Technologies’ IPO.
6. Paras Defence is one of the few players having an edge in defence deals.