import re
regex = re.compile(r"(?m) (?<!^)(?=\d+\.)")
test_str = ("Giovinni Enrico\n"
"I GIO MORET FMJ\n"
"1.Air Jordan 2.Nike 3.Prada\n"
"4.Dolce & Gabbana 5.2.2.Diesel\n"
"Adriana Cazetto\n"
"ADRE CX GF 1.Air Jordan \n"
"2.Adidas 3.LV\n"
"4.2.8. Gucci")
subst = "\\n"
result = regex.sub(subst, test_str)
if result:
print(result)
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Python, please visit: https://docs.python.org/3/library/re.html