fork download
  1. import re
  2. p = re.compile(r'^([ \t]*\d\.)\s+(?=\d+)', re.MULTILINE)
  3. s = """6. Some text ending in a number 2. 23-Feb-2012
  4. 6. 1 More text 3. 2017 is a year
  5. 6. 2
  6. 6. 7
  7. """
  8. res = p.sub(r"\1", s)
  9. print(res)
Success #stdin #stdout 0.01s 8968KB
stdin
Standard input is empty
stdout
6. Some text ending in a number 2. 23-Feb-2012
 6.1 More text 3. 2017 is a year
  6.2
   6.7