I would like to highlight the word that is equal to "searchTerm" within a String. I managed to highlight the whole String with code below. Can someone explain me how to do that? As i know it can be done with attributed string but i have no experience with it.
Text(gesetzestextSKV.marginale)
.fontWeight(.bold)
.fixedSize(horizontal: false, vertical: true)
.padding(.leading)
.padding(gesetzestextSKV.marginale.isEmpty ? -20.0 : 0)
.background(gesetzestextSKV.marginale.localizedCaseInsensitiveContains(searchTerm) ? Color.yellow : nil)