from_string

visualife.utils.from_string(text, first, last, default)

Simple text extractor with a default value.

Extracts a substring of a given string and trims white characters from the extracted part. If the result is an empty string (i.e. there were no meaningful characters in the given region), the default value is returned

Parameters:
  • text – (string) a source string
  • first – (int) the index of the first character to be extracted
  • last – (int) the index of the position behind the last character to be extracted
  • default – a value returned when an empty string is extracted
Returns:

a substring or the given default