From 093ec128d5732b02e75df2566c7db2c6e381d766 Mon Sep 17 00:00:00 2001 From: Leonard Richardson Date: Sun, 10 Jun 2012 06:33:55 -0400 Subject: Made it clear in the doc that Beautiful Soup calls search() on regular expressions, not match() --- doc/source/index.rst | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'doc/source') diff --git a/doc/source/index.rst b/doc/source/index.rst index 16c6020..e5e3fbc 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -1026,16 +1026,23 @@ A regular expression ^^^^^^^^^^^^^^^^^^^^ If you pass in a regular expression object, Beautiful Soup will filter -against that regular expression. This code finds all the tags whose -names start with the letter "b"; in this case, the tag and the - tag:: +against that regular expression using its ``match()`` method. This code +finds all the tags whose names start with the letter "b"; in this +case, the tag and the tag:: import re - for tag in soup.find_all(re.compile("b.*")): + for tag in soup.find_all(re.compile("^b")): print(tag.name) # body # b +This code finds all the tags whose names contain the letter 't':: + + for tag in soup.find_all(re.compile("t")): + print(tag.name) + # html + # title + .. _a list: A list -- cgit v1.2.3