split_selection#
- omni.kit.widget.highlight_label.highlight_label.split_selection(text, selection, match_case: bool = False)#
Splits the provided text into a list of substrings to facilitate drawing segments of selected text.
The resulting list alternates between unselected and selected text, starting with an unselected portion. If the entire text is selected, it returns a list starting with an empty string followed by the entire text.
- Parameters:
text (str) – The text to split based on the selection.
selection (str) – The substring to search for within `text`.
match_case (bool, optional) – If True, the search is case-sensitive; otherwise, it’s case-insensitive. Defaults to False.
- Returns:
A list containing the split parts of the text with the selection highlighted.
- Return type:
list of str
Examples
split_selection(“helloworld”, “o”) -> [“hell”, “o”, “w”, “o”, “rld”]
split_selection(“helloworld”, “helloworld”) -> [“”, “helloworld”]