Member Junction
    Preparing search index...

    HighlightUtil - Utility class for highlighting search matches in text

    This class provides methods to:

    1. Check if text matches a search term (with SQL-style % wildcard support)
    2. Highlight matching portions of text with HTML markup

    The key distinction is that highlighting should only occur when the text actually matches the search pattern. For wildcard searches like "food%ass", the text must contain "food" followed by "ass" in order - we shouldn't highlight partial matches that don't satisfy the full pattern.

    Index

    Constructors

    Methods

    • Highlight matching text in a string based on the filter text. IMPORTANT: Only highlights if the text actually matches the pattern. For wildcard searches, all segments must be present in order.

      Parameters

      • text: string

        The text to highlight

      • searchTerm: string

        The search term (may include % wildcards)

      • escapeHtml: boolean = true

        Whether to escape HTML characters (default: true)

      Returns string

      HTML string with highlighted matches, or the original text if no match

    • Check if a value matches the search term (supports SQL-style % wildcards) This is used for filtering records.

      Parameters

      • value: string

        The text value to check

      • searchTerm: string

        The search term (may include % wildcards)

      Returns boolean

      true if the value matches the search pattern