icat.utils.add_highlights#
- icat.utils.add_highlights(text, regex, color='yellow')#
Adds HTML span tag highlights around any matches in the text for the given regex.
- Parameters:
text (str) – The text to add highlights to.
regex (str) – The regular expression to search for and sub in the text. Note that this needs to have one capture group, so the regex should be wrapped in ‘()’.
color (str) – The background color to highlight the text with.
- Return type:
str
Note
The regular expression will be treated as case insensitive.