pyxx.strings

Code for processing, parsing, and modifying strings

The pyxx.strings module is intended to assist with processing data in the form of Python strings. Submodules provide functionality such as analyzing strings with parentheses (e.g., determining which parentheses in a string are “matched” with each other), assisting with string indexing and splitting, and checking string content.

Analyzing String Content

The functions in this section can be used to analyze string content, checking whether certain characters or patterns are present or whether the string content has a particular structure.

str_excludes_chars(value, prohibited_chars)

Checks that a string does not contain any of a specified list of prohibited characters

str_includes_only(value, allowed_chars)

Checks that a string contains only characters present in a specified set of characters

Bracket Parsing

The objects in this section are intended to assist in processing strings with brackets, loosely defined as pairs of characters that enclose quantities of interest ((), [], {}, etc.). Particularly in scientific contexts, it can be useful to parse strings containing brackets and identify pairs of matched brackets.

Note

For more information on terminology definitions and how the functions in this section operate on a conceptual level, refer to the Bracket Concepts page.

contains_all_matched_brackets(value[, ...])

Checks whether all opening brackets in a string have a corresponding closing bracket

find_matching_bracket(value, begin[, ...])

Finds the index of the bracket that forms a matched pair with another bracket at a given index

find_skip_brackets(value, target_chars, begin)

Finds the index of a target character, skipping over matched brackets

strip_matched_brackets(value[, max_pairs, ...])

Remove matched leading/trailing brackets from strings

Splitting Strings

The functions in this section can be used to analyze strings and split them into sub-strings or lists of strings.

split_at_index(value, index[, return_index])

Splits a string at a given index