consecutive_find¶
-
visualife.utils.consecutive_find(string, shortest_accepted=2, allowed_chars=[])¶ Detects ranges of identical characters in a given string.
For example:
consecutive_find("AAABBCCCAAA")
should return:
[[0, 2, 'A'], [3, 4, 'B'], [5, 7, 'C'], [8, 10, 'A']]
Parameters: - string – (
string) input string - shortest_accepted – (
int) shortest substring accepted - allowed_chars – (
list[char]) list of allowed characters: the returned list will hold a given block if and only if
its character is on the list; when the list is empty, all characters are allowed :return: a list of segments defining substrings of identical characters
- string – (