From 7329175453357e315463663edfaf5890abc52ea3 Mon Sep 17 00:00:00 2001 From: Neil Mitchell Date: Fri, 28 May 2021 15:08:50 +0100 Subject: [PATCH] Make it clear the prefix/suffix is removed at most once --- spec.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/spec.md b/spec.md index b555c66..3cbfeb5 100644 --- a/spec.md +++ b/spec.md @@ -3933,7 +3933,8 @@ If S does not contain `x`, `partition` returns `(S, "", "")`. ### string·removeprefix -`S.removeprefix(x)` removes the prefix `x` from the string S and returns the rest of the string. +`S.removeprefix(x)` removes the prefix `x` from the string S at most once, +and returns the rest of the string. If the prefix string is not found then it returns the original string. `removeprefix` fails if `x` is not a string. @@ -3941,12 +3942,14 @@ If the prefix string is not found then it returns the original string. ```python "banana".removeprefix("ban") # "ana" "banana".removeprefix("ana") # "banana" +"bbaa".removeprefix("b") # "baa" ``` ### string·removesuffix -`S.removesuffix(x)` removes the suffix `x` from the string S and returns the rest of the string. +`S.removesuffix(x)` removes the suffix `x` from the string S at most once, +and returns the rest of the string. If the suffix string is not found then it returns the original string. `removesuffix` fails if `x` is not a string. @@ -3954,6 +3957,7 @@ If the suffix string is not found then it returns the original string. ```python "banana".removesuffix("ana") # "ban" "banana".removesuffix("ban") # "banana" +"bbaa".removesuffix("a") # "bba" ```