diff options
Diffstat (limited to 'Doc/library/re.rst')
-rw-r--r-- | Doc/library/re.rst | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/Doc/library/re.rst b/Doc/library/re.rst index 55663ec..1239434 100644 --- a/Doc/library/re.rst +++ b/Doc/library/re.rst @@ -1120,15 +1120,15 @@ does by default). For example:: - >>> re.match("c", "abcdef") # No match - >>> re.search("c", "abcdef") # Match + >>> re.match("c", "abcdef") # No match + >>> re.search("c", "abcdef") # Match <_sre.SRE_Match object at ...> Regular expressions beginning with ``'^'`` can be used with :func:`search` to restrict the match at the beginning of the string:: - >>> re.match("c", "abcdef") # No match - >>> re.search("^c", "abcdef") # No match + >>> re.match("c", "abcdef") # No match + >>> re.search("^c", "abcdef") # No match >>> re.search("^a", "abcdef") # Match <_sre.SRE_Match object at ...> @@ -1209,9 +1209,9 @@ a function to "munge" text, or randomize the order of all the characters in each word of a sentence except for the first and last characters:: >>> def repl(m): - ... inner_word = list(m.group(2)) - ... random.shuffle(inner_word) - ... return m.group(1) + "".join(inner_word) + m.group(3) + ... inner_word = list(m.group(2)) + ... random.shuffle(inner_word) + ... return m.group(1) + "".join(inner_word) + m.group(3) >>> text = "Professor Abdolmalek, please report your absences promptly." >>> re.sub(r"(\w)(\w+)(\w)", repl, text) 'Poefsrosr Aealmlobdk, pslaee reorpt your abnseces plmrptoy.' |