From 45662a5c914a1fb896bbdbbc26be5b3ea598cc51 Mon Sep 17 00:00:00 2001 From: Albert Villanova del Moral <8515462+albertvillanova@users.noreply.github.com> Date: Sat, 13 Jul 2019 12:21:03 +0200 Subject: [PATCH] Remove inline flags from the middle of a regex Fix #181 --- WikiExtractor.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/WikiExtractor.py b/WikiExtractor.py index 730b3bab..04779cc4 100755 --- a/WikiExtractor.py +++ b/WikiExtractor.py @@ -2445,16 +2445,16 @@ def makeInternalLink(title, label): EXT_LINK_URL_CLASS = r'[^][<>"\x00-\x20\x7F\s]' ANCHOR_CLASS = r'[^][\x00-\x08\x0a-\x1F]' ExtLinkBracketedRegex = re.compile( - '\[(((?i)' + '|'.join(wgUrlProtocols) + ')' + EXT_LINK_URL_CLASS + r'+)' + + '\[((' + '|'.join(wgUrlProtocols) + ')' + EXT_LINK_URL_CLASS + r'+)' + r'\s*((?:' + ANCHOR_CLASS + r'|\[\[' + ANCHOR_CLASS + r'+\]\])' + r'*?)\]', - re.S | re.U) + re.I | re.S | re.U) # A simpler alternative: # ExtLinkBracketedRegex = re.compile(r'\[(.*?)\](?!])') EXT_IMAGE_REGEX = re.compile( r"""^(http://|https://)([^][<>"\x00-\x20\x7F\s]+) - /([A-Za-z0-9_.,~%\-+&;#*?!=()@\x80-\xFF]+)\.((?i)gif|png|jpg|jpeg)$""", - re.X | re.S | re.U) + /([A-Za-z0-9_.,~%\-+&;#*?!=()@\x80-\xFF]+)\.(gif|png|jpg|jpeg)$""", + re.I | re.X | re.S | re.U) def replaceExternalLinks(text):