strutils¶
-
bedrock.strutils.
remove
(text, what, count=None, strip=False)[source]¶ Like
replace
, wherenew
replacement is an empty string.
-
bedrock.strutils.
remove_each
(text, items, count=None, strip=False)[source]¶ Like
remove
, where each occurrence initems
iswhat
to remove.
-
bedrock.strutils.
replace
(text, old, new, count=None, strip=False)[source]¶ Replace an
old
subset oftext
withnew
.old
type may be either a string or regular expression.If
strip
, remove all leading/trailing whitespace.If
count
, replace the specified number of occurence, otherwise replace all.
-
bedrock.strutils.
replace_each
(text, items, count=None, strip=False)[source]¶ Like
replace
, where each occurrence initems
is a 2-tuple of(old, new)
pair.
-
bedrock.strutils.
splitter
(text, token=None, expected=2, default=u'', strip=False)[source]¶ Split
text
bytoken
into at leastexpected
number of results.When
token
isNone
, the default for Pythonstr.split
is used, which will split on all whitespace.token
may also be a regex.If actual number of results is less than
expected
, pad withdefault
.If
strip
, than do just that to each result.