@inherits FnzComponentBase @code { [Parameter, Required] public string Text { get; set; } [Parameter, Required] public IReadOnlyCollection Keywords { get; set; } } @if (string.IsNullOrEmpty(Text) == false) { var lowerText = Text.ToLower(); for (var index = 0; index < Text.Length; ++index) { bool match = false; foreach (var kw in Keywords.Where(p => string.IsNullOrEmpty(p) == false).OrderByDescending(p => p.Length)) { match = true; var lowerKw = kw.ToLower(); for (var ki = 0; ki < kw.Length; ++ki) { if (index + ki >= Text.Length || lowerText[index + ki] != lowerKw[ki]) { match = false; break; } } if (match) { @Text.Substring(index,kw.Length) index += kw.Length - 1; break; } } if (index < Text.Length && match == false) { @Text[index] } } }