bpod_core.misc.sanitize_string

bpod_core.misc.sanitize_string(string, substitute='_')

Replace non-alphanumeric characters in a string with a given substitute.

Parameters:
  • string (str) – The input string to be sanitized.

  • substitute (str, optional) – The character(s) to replace non-alphanumeric characters with. Defaults to ‘_’.

Returns:

A sanitized string where all non-alphanumeric characters have been replaced with the specified substitute.

Return type:

str

Raises:

TypeError – If either string or substitute is not an instance of str.