highlightText

Type:Function
Status:stable
Since:1.0.0
Platform:jsnode
@blackbyte.sugar.shared.string

This function allows you to highlight some text in a string or in an HTMLElement

Params

  1. ctx*-String|HTMLElement

    The string or HTMLElement in which to highlight the text

  2. search*-String|String[]|RegExp

    The text to highlight

Return

  1. -String|HTMLElement

    The processed string or HTMLElement

Example

import { highlightText } from '@blackbyte/sugar/string';
highlightText('Hello world', 'llo'); // => He<span class="-highlight">llo</span> world

Todo

  • testsnormal