# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r".(?=.{4})"
test_str = ("usdfiusdgfisdgf\n"
"LovePizza\n"
"12,34,56,78\n"
"12.34.56,78\n"
"Esto es una prueba\n"
"hola\n"
"12345678\n"
"45345345343\n"
"Nananananananananananananananana Batman!\n"
"nada@gmail.com\n"
"lorena.loba@loquesea.gov.co\n"
"hola_3@gmail.com\n"
"adios@gmail.com\n"
"pruebagmail.com\n"
"pepe.trueno \n"
"patricia99.rica@.hotmail.com\n"
"lorena22.regalada\n"
"comercio.enproceso\n"
"daniela regalo\n\n"
"gmail.com\n"
"redluis.luis@gmail.com\n"
"pepe_redluis@gmail.com\n"
"pepe_redluis@gmail.com\n"
"mart-red+luis@gmail.com.ve\n\n"
"{\n"
"\"servicio\":\"eval\",\n"
"\"eval\":{\n"
"\"10441\":\"valor.%substr%( 2, 2 )\",\n"
"\"10442\":\"valor\",\n"
"\"10443\":\"%mask%(valor,3)\"\n"
"},\n"
"\"operacion\":\"valor.%concat%(10442,10443,10441)\",\n"
"\"resultado\":12022\n"
"}\n\n\n"
"1. Luciana: 4.216 \n"
"2. Isabella: 3.505 \n"
"3. Salomé: 2.829\n"
"4. Emmanuel: 2.688\n"
"5. Antonella: 2.643\n"
"6. Emiliano: 2454\n"
"7. Santiago: 2.383\n"
"8. Samuel: 2.256\n"
"9. Jerónimo: 2.167\n"
"10. Mariana: 2.160\n\n"
"date,home_team,away_team,home_score,away_score,tournament,city,country,neutral\n"
"1872-11-30,Scotland,England,0,0,Friendly,Glasgow,Scotland,FALSE\n"
"1873-03-08,England,Scotland,4,2,Friendly,London,England,FALSE\n"
"1874-03-07,Scotland,England,2,1,Friendly,Glasgow,Scotland,FALSE\n"
"1875-03-06,England,Scotland,2,2,Friendly,London,England,FALSE\n"
"1876-03-04,Scotland,England,3,0,Friendly,Glasgow,Scotland,FALSE\n"
"1876-03-25,Scotland,Wales,4,0,Friendly,Glasgow,Scotland,FALSE\n\n"
"1::Toy Story (1995)::Adventure|Animation|Children|Comedy|Fantasy\n"
"2::Jumanji (1995)::Adventure|Children|Fantasy\n"
"3::Grumpier Old Men (1995)::Comedy|Romance\n"
"4::Waiting to Exhale (1995)::Comedy|Drama|Romance\n"
"5::Father of the Bride Part II (1995)::Comedy\n"
"6::Heat (1995)::Action|Crime|Thriller\n"
"7::Sabrina (1995)::Comedy|Romance\n"
"8::Tom and Huck (1995)::Adventure|Children\n"
"9::Sudden Death (1995)::Action\n"
"10::GoldenEye (1995)::Action|Adventure|Thriller\n"
"11::American President, The (1995)::Comedy|Drama|Romance\n"
"12::Dracula: Dead and Loving It (1995)::Comedy|Horror\n"
"13::Balto (1995)::Animation|Children\n"
"14::Nixon (1995)::Drama\n"
"15::Cutthroat Island (1995)::Action|Adventure|Romance\n"
"16::Casino (1995)::Crime|Drama\n"
"17::Sense and Sensibility (1995)::Comedy|Drama|Romance\n"
"18::Four Rooms (1995)::Comedy|Drama|Thriller\n"
"19::Ace Ventura: When Nature Calls (1995)::Comedy\n"
"20::Money Train (1995)::Action|Comedy|Crime|Drama|Thriller")
subst = ""
# You can manually specify the number of replacements by changing the 4th argument
result = re.sub(regex, subst, test_str, 0, re.MULTILINE | re.IGNORECASE)
if result:
print (result)
# Note: for Python 2.7 compatibility, use ur"" to prefix the regex and u"" to prefix the test string and substitution.
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