strutils¶
-
bedrock.strutils.remove(text, what, count=None, strip=False)[source]¶ Like
replace, wherenewreplacement is an empty string.
-
bedrock.strutils.remove_each(text, items, count=None, strip=False)[source]¶ Like
remove, where each occurrence initemsiswhatto remove.
-
bedrock.strutils.replace(text, old, new, count=None, strip=False)[source]¶ Replace an
oldsubset oftextwithnew.oldtype 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 initemsis a 2-tuple of(old, new)pair.
-
bedrock.strutils.splitter(text, token=None, expected=2, default=u'', strip=False)[source]¶ Split
textbytokeninto at leastexpectednumber of results.When
tokenisNone, the default for Pythonstr.splitis used, which will split on all whitespace.tokenmay also be a regex.If actual number of results is less than
expected, pad withdefault.If
strip, than do just that to each result.