summaryrefslogtreecommitdiff
path: root/doc/source
diff options
context:
space:
mode:
authorLeonard Richardson <leonardr@segfault.org>2012-06-10 06:33:55 -0400
committerLeonard Richardson <leonardr@segfault.org>2012-06-10 06:33:55 -0400
commit093ec128d5732b02e75df2566c7db2c6e381d766 (patch)
tree184f676b44ddc0b8df21bbebd38b60ad85bd3990 /doc/source
parent8aabeecd08d6ac154610ed8ea8d3261077814a4d (diff)
Made it clear in the doc that Beautiful Soup calls search() on regular expressions, not match()
Diffstat (limited to 'doc/source')
-rw-r--r--doc/source/index.rst15
1 files changed, 11 insertions, 4 deletions
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 <body> tag and the
-<b> 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 <body> tag and the <b> 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