diff --git a/dosagelib/util.py b/dosagelib/util.py index c3ea71748..20f9ad906 100644 --- a/dosagelib/util.py +++ b/dosagelib/util.py @@ -45,7 +45,7 @@ def tagre(tag, attribute, value, quote='"'): value=value, quote=quote, ) - return r'<\s*%(tag)s\s+[^>]*%(attribute)s\s*=\s*%(quote)s%(value)s%(quote)s[^>]*>' % attrs + return r'<\s*%(tag)s\s+(?:[^>]*\s+)?%(attribute)s\s*=\s*%(quote)s%(value)s%(quote)s[^>]*>' % attrs def case_insensitive_re(name): diff --git a/tests/test_util.py b/tests/test_util.py index 089d98ef2..dcb67be37 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -76,9 +76,10 @@ class RegexTest(TestCase): self.match_tag(matcher, tag, value, domatch) def match_tag(self, matcher, tag, value, domatch=True): - match = matcher.match(tag % value) + text = tag % value + match = matcher.search(text) if domatch: - self.assertTrue(match) + self.assertTrue(match, "%s should match %s" % (matcher.pattern, text)) self.assertEqual(match.group(1), value) else: - self.assertFalse(match) + self.assertFalse(match, "%s should not match %s" % (matcher.pattern, text))