Skip to content

Commit 6272577

Browse files
committed
gh-106318: Add examples for str.replace() method
1 parent 8a508e0 commit 6272577

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Doc/library/stdtypes.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2398,17 +2398,19 @@ expression support in the :mod:`re` module).
23982398
Return a copy of the string with all occurrences of substring *old* replaced by
23992399
*new*. If *count* is given, only the first *count* occurrences are replaced.
24002400
If *count* is not specified or ``-1``, then all occurrences are replaced.
2401+
For example:
24012402

2402-
.. versionchanged:: 3.13
2403-
*count* is now supported as a keyword argument.
2404-
2405-
For example::
2403+
.. doctest::
24062404

24072405
>>> 'spam, spam, spam'.replace('spam', 'eggs')
24082406
'eggs, eggs, eggs'
24092407
>>> 'spam, spam, spam'.replace('spam', 'eggs', 1)
24102408
'eggs, spam, spam'
24112409

2410+
.. versionchanged:: 3.13
2411+
*count* is now supported as a keyword argument.
2412+
2413+
24122414
.. method:: str.rfind(sub[, start[, end]])
24132415

24142416
Return the highest index in the string where substring *sub* is found, such

0 commit comments

Comments
 (0)