Tkap1

Regex

Jan 29th, 2019
383
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.33 KB | None | 0 0
  1. import re
  2.  
  3. with open("textos.txt") as source:
  4.     fullText = source.read()
  5.    
  6.     match = re.findall("(\\.\d+.+?)(?=(\\.\d+|\Z))", fullText, re.DOTALL)
  7.     for text in match:
  8.         lines = text[0].split("\n")
  9.         title = lines[0]
  10.         content = "\n".join(lines[1:])
  11.         with open(title + ".txt", "w") as output:
  12.             output.write(title + "\n" + content)
Add Comment
Please, Sign In to add comment