# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"(\((.*?)\))"
test_str = ("Chats (Felis catus)\n"
"Chiens (Canis lupus familiaris)\n"
"Chevaux (Equus ferus caballus)\n"
"Moutons (Ovis aries)\n"
"Bovins (Bos taurus taurus)\n"
"Porcs (Susscrofa domestica)\n"
"Chèvres (Capra aegagrus hircus)\n"
"Les lapins (Oryctolagus cuniculus)\n"
"Les canards (Anas platyrhyncos domesticus)\n"
"Les dindons (Meleagris gallopavo gallopavo)\n"
"Ânes (Equus asinus)\n"
"Mules (Equus asinus x Equus caballus)\n"
"Chien\n"
"Chat\n"
"Furet\n"
"Cheval\n"
"âne\n"
"vache\n"
"lama\n"
"mule\n"
"Porc\n"
"Cochon d'Inde\n"
"Rat domestique\n"
"Hamster doré\n"
"Souris domestique\n"
"gerbille de Mongolie\n"
"Lapin domestique\n"
"Canard colvert\n"
"Poule \n"
"paon\n"
"Pigeon\n"
"tourterelle\n"
"colombe\n"
"Canari\n"
"Perruche\n"
"Poisson rouge\n"
"Carpe koï\n"
"axolotl\n")
subst = ""
# You can manually specify the number of replacements by changing the 4th argument
result = re.sub(regex, subst, test_str, 0, re.MULTILINE)
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