# -*- coding: utf-8 -*-
import re
regtitlepreprocess = re.compile(r'([^<]*)',re.MULTILINE | re.DOTALL)
regdeflist = re.compile(r'(\n;[^:\n]*:)')
regsentinitialbracket = re.compile(r'([^M][^rs]\.)\s+(\[\[([^|\]]+\|)?([A-Z])([^|\]]+)\]\])',re.MULTILINE | re.DOTALL)
regneosfirst = re.compile(r'()+\s*()+\s*()*\s?', re.MULTILINE | re.DOTALL)
regneosfinal = re.compile(r'()*\s*()+\s*()+\s?', re.MULTILINE | re.DOTALL)
regneosremove = re.compile(r'', re.MULTILINE | re.DOTALL)
regeos = re.compile(r'\s?', re.MULTILINE | re.DOTALL)
regeosTwoOrMore = re.compile(r'((\s*)|(\s?\n)){3-10}', re.MULTILINE | re.DOTALL)
regredirect = re.compile(r'#[rR][eE][dD][iI][rR][eE][cC][tT]\s?\[\[([^\]]+)\]\]', re.MULTILINE | re.DOTALL )
regcurly1 = re.compile(r'(\({{[^}^{]*?}}\)|\'*{{[^}^{]*?}}\'*)', re.MULTILINE | re.DOTALL)
reglongTemp = re.compile(r'{{[^}^{]{500,10000000}}}\)|\'*{{[^}^{]{500,10000000}}}', re.MULTILINE | re.DOTALL)
regboxtable = re.compile(r'{{[^}^{]*?(box|table)[^}^{]*}}', re.MULTILINE | re.DOTALL)
regwikitable1 = re.compile(r'{[^}]*?class="?wikitable"?[^}]*?}', re.MULTILINE | re.DOTALL)
regwikitable2 = re.compile(r'[^{]{\|[^\\][^}^{]*?}', re.MULTILINE | re.DOTALL)
regwikitable3 = re.compile(r'([^{]|^){\|[^\\].{0,10000}?\|}', re.MULTILINE | re.DOTALL)
regtable = re.compile(r'<\s?table[^/]{0,100}>.{0,30000}\s?table.{0,10}>', re.MULTILINE | re.DOTALL)
regtableborder = re.compile(r'<\s?TABLE[^/]{0,100}>.{0,30000}\s?TABLE.{0,10}>', re.MULTILINE | re.DOTALL)
#regtableConvertStart = re.compile(r'{\|', re.MULTILINE | re.DOTALL)
#regtableConvertEnd = re.compile(r'\|}', re.MULTILINE | re.DOTALL)
#regtableStephan = re.compile(r'\{\|(?:(?!\{\|)(?!\|\}).)+?\|\}')
"""
regtableStephanImproved = re.compile(r'{\|(?:(?!{\|)(?!\|}).)+?\|}', re.MULTILINE | re.DOTALL)
regtableStephanImproved2 = re.compile(r'^[:*]{0,4}{\|(?:(?!^[:*]{0,4}\|}).)+^[:*]{0,4}\|}', re.MULTILINE | re.DOTALL)
regtableStephanImproved3 = re.compile(r'^[:* ]{0,4}{\|(?:(?!^[:* ]{0,4}(?:{\||\|})).)+?^[:* ]{0,4}\|}', re.MULTILINE | re.DOTALL)
"""
regtableClean = re.compile(r'(^[:* ]{0,4}|^(<[^>]*?>)\s*(<[^>]*?>)*\s*){\|(?:(?!^[:* ]{0,4}(?:{\||\|})).)+?^[:* ]{0,4}\|}', re.MULTILINE | re.DOTALL)
regtablestart = re.compile(r'(^[:* ]{0,4}|^(<[^>]*?>)\s*(<[^>]*?>)*\s*){\|')
#regtableGisleImproved = re.compile(r'^[:* ]{0,4}{\|(?:(?!^[:* ]{0,4}\|}).)(?:(?!^[:* ]{0,4}{\|).)+?^[:* ]{0,4}\|}', re.MULTILINE | re.DOTALL)
regmultiplePipes = re.compile(r'(\|.[^\|]*){20,100000}')
#regtableStephan = re.compile(r'{\|(?:(?!{\|).)+\|}')
#DEPRECATED
regtableConvertStart = re.compile(r'(^.)?{\|(?=([^\\].{0,400000}?\|}))', re.MULTILINE | re.DOTALL)
regtableConvertEnd = re.compile(r'(Ӂ.{0,400000}?)(\|})', re.MULTILINE | re.DOTALL)
regtableConvertRevertStart = re.compile(r'Ӂ', re.MULTILINE | re.DOTALL)
regtableConvertRevertEnd = re.compile(r'ጣ', re.MULTILINE | re.DOTALL)
regtableConverted = re.compile(r'Ӂ[^Ӂ]{0,400000}?ጣ', re.MULTILINE | re.DOTALL)
regtablehardcode = re.compile('{\|\sclass=\"wikitable\"\s!English\s\|\|\sFrench\s\|\|\sIPA pronunciation\s\(Canadian accent\).*?\|}', re.MULTILINE | re.DOTALL)
regeos = re.compile(r'\s?', re.MULTILINE | re.DOTALL)
regeosmathnowiki = re.compile(r'', re.MULTILINE | re.DOTALL)
regbr = re.compile(r'
', re.MULTILINE | re.DOTALL)
regref = re.compile(r'<[Rr]ef.*?/[Rr]ef>', re.MULTILINE | re.DOTALL)
regref2 = re.compile(r'<[Rr]ef[^>]*?/>', re.MULTILINE | re.DOTALL)
regcomment = re.compile(r'', re.MULTILINE | re.DOTALL)
regblockquote = re.compile(r'
(.*?)
',re.MULTILINE | re.DOTALL)
regsource = re.compile(r')', re.MULTILINE | re.DOTALL)
#regremoveeosinsource2 = re.compile(r'(.{0,5000}?)', re.MULTILINE | re.DOTALL)
#regremoveeosincode2 = re.compile(r'(.{0,5000}?
)', re.MULTILINE | re.DOTALL)
#TRYING THE OLD
regremoveeosinsource2 = re.compile(r'()', re.MULTILINE | re.DOTALL)
regremoveeosincode2 = re.compile(r'()', re.MULTILINE | re.DOTALL)
regremoveeosincode = re.compile(r'(
(.*)*?(.*?)', re.MULTILINE | re.DOTALL)
regremoveeosinmath2 = re.compile(r'()', re.MULTILINE | re.DOTALL)
regremoveeosinnowiki2 = re.compile(r'(.{0,5000}?)', re.MULTILINE | re.DOTALL)
#ORIGINAL:
#regremoveeosinnowiki = re.compile(r'((.*)*?(.*?)', re.MULTILINE | re.DOTALL)
#not multiline/dotall
#regremoveeosinnowiki = re.compile(r'((.*)*?(.*?)')
#not multiline/dotall - not tag
#regremoveeosinnowiki = re.compile(r'(.*)(.*)*?(.*?)')
regremovenowiki = re.compile(r'')
#length constraint
#regremoveeosinnowiki = re.compile(r'((.{0,500})*?(.{0,500})', re.MULTILINE | re.DOTALL)
#length constraint - no multiline
#regremoveeosinnowiki = re.compile(r'((.{0,500})*?(.{0,500})')
#regremoveeosinnowiki = re.compile(r'(.{0,500})(.{0,500}){0,30}(.{0,500})')
#multiple: - greedy
regremoveeosinnowiki = re.compile(r'([^<]{0,500}?)()(.{0,500}?)', re.MULTILINE | re.DOTALL)
#regdigitandbold = re.compile(r'(^:"[0-9][0-9]\.\s+(?=\'))', re.MULTILINE | re.DOTALL)
#regcurly1 = re.compile(r'{{?[^}^{]*?}?}', re.MULTILINE | re.DOTALL)
#regsource1 = re.compile(r'