strutils

bedrock.strutils.is_regex(obj)[source]

Check if obj is a regular expression

bedrock.strutils.is_string(obj)[source]

Check if obj is a string

bedrock.strutils.matches(text, what)[source]

Check if what occurs in text

bedrock.strutils.remove(text, what, count=None, strip=False)[source]

Like replace, where new replacement is an empty string.

bedrock.strutils.remove_each(text, items, count=None, strip=False)[source]

Like remove, where each occurrence in items is what to remove.

bedrock.strutils.replace(text, old, new, count=None, strip=False)[source]

Replace an old subset of text with new.

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 in items is a 2-tuple of (old, new) pair.

bedrock.strutils.splitter(text, token=None, expected=2, default=u'', strip=False)[source]

Split text by token into at least expected number of results.

When token is None, the default for Python str.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 with default.

If strip, than do just that to each result.