]> granicus.if.org Git - python/commitdiff
Added a note and examples to explain that re.split does not split on an
authorSkip Montanaro <skip@pobox.com>
Sat, 1 Sep 2007 17:40:03 +0000 (17:40 +0000)
committerSkip Montanaro <skip@pobox.com>
Sat, 1 Sep 2007 17:40:03 +0000 (17:40 +0000)
empty pattern match. (issue 852532).

Doc/library/re.rst

index d5abcdd2a270a2930bf43316b5e9d85a33081b6a..e01a8cc72627b7424c073a3b1e795d2dc09d9cee 100644 (file)
@@ -544,6 +544,13 @@ form.
       >>> re.split('\W+', 'Words, words, words.', 1)
       ['Words', 'words, words.']
 
+   Note that *split* will never split a string on an empty pattern match.
+   For example ::
+
+      >>> re.split('x*', 'foo')
+      ['foo']
+      >>> re.split("(?m)^$", "foo\n\nbar\n")
+      ['foo\n\nbar\n']
 
 .. function:: findall(pattern, string[, flags])