From 1fef18118339237de025ed15dc6df4c39315b55d Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Thu, 23 Oct 1997 19:09:21 +0000 Subject: [PATCH] Although it's hard to be sure, I *think* this is a working conversion from regex to re style regular expressions. This should make sgmllib and htmllib threadsafe, so I can now create a threaded version of webchecker... --- Lib/sgmllib.py | 130 ++++++++++++++++++++++++------------------------- 1 file changed, 65 insertions(+), 65 deletions(-) diff --git a/Lib/sgmllib.py b/Lib/sgmllib.py index 8f320018800..8baf519e709 100644 --- a/Lib/sgmllib.py +++ b/Lib/sgmllib.py @@ -8,34 +8,34 @@ # and CDATA (character data -- only end tags are special). -import regex +import re import string # Regular expressions used for parsing -interesting = regex.compile('[&<]') -incomplete = regex.compile('&\([a-zA-Z][a-zA-Z0-9]*\|#[0-9]*\)?\|' - '<\([a-zA-Z][^<>]*\|' - '/\([a-zA-Z][^<>]*\)?\|' - '![^<>]*\)?') +interesting = re.compile('[&<]') +incomplete = re.compile('&([a-zA-Z][a-zA-Z0-9]*|#[0-9]*)?|' + '<([a-zA-Z][^<>]*|' + '/([a-zA-Z][^<>]*)?|' + '![^<>]*)?') -entityref = regex.compile('&\([a-zA-Z][a-zA-Z0-9]*\)[^a-zA-Z0-9]') -charref = regex.compile('&#\([0-9]+\)[^0-9]') +entityref = re.compile('&([a-zA-Z][a-zA-Z0-9]*)[^a-zA-Z0-9]') +charref = re.compile('&#([0-9]+)[^0-9]') -starttagopen = regex.compile('<[>a-zA-Z]') -shorttagopen = regex.compile('<[a-zA-Z][a-zA-Z0-9]*/') -shorttag = regex.compile('<\([a-zA-Z][a-zA-Z0-9]*\)/\([^/]*\)/') -endtagopen = regex.compile('a-zA-Z]') -endbracket = regex.compile('[<>]') -special = regex.compile(']*>') -commentopen = regex.compile('