From 3c133d8d12f314ff3d70195cc0422e8e087b7829 Mon Sep 17 00:00:00 2001 From: Leonard Richardson Date: Thu, 11 Dec 2014 22:08:09 -0500 Subject: The select() method can now find tags whose names contain dashes. Patch by Francisco Canas [bug=1276211] --- bs4/element.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'bs4/element.py') diff --git a/bs4/element.py b/bs4/element.py index 197722d..1127c7a 100644 --- a/bs4/element.py +++ b/bs4/element.py @@ -548,17 +548,17 @@ class PageElement(object): # Methods for supporting CSS selectors. - tag_name_re = re.compile('^[a-z0-9]+$') - - # /^(\w+)\[(\w+)([=~\|\^\$\*]?)=?"?([^\]"]*)"?\]$/ - # \---/ \---/\-------------/ \-------/ - # | | | | - # | | | The value - # | | ~,|,^,$,* or = - # | Attribute + tag_name_re = re.compile('^[a-zA-Z0-9][-.a-zA-Z0-9:_]*$') + + # /^([a-zA-Z0-9][-.a-zA-Z0-9:_]*)\[(\w+)([=~\|\^\$\*]?)=?"?([^\]"]*)"?\]$/ + # \---------------------------/ \---/\-------------/ \-------/ + # | | | | + # | | | The value + # | | ~,|,^,$,* or = + # | Attribute # Tag attribselect_re = re.compile( - r'^(?P\w+)?\[(?P\w+)(?P[=~\|\^\$\*]?)' + + r'^(?P[a-zA-Z0-9][-.a-zA-Z0-9:_]*)?\[(?P\w+)(?P[=~\|\^\$\*]?)' + r'=?"?(?P[^\]"]*)"?\]$' ) -- cgit v1.2.3