mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
7 lines
233 B
TypeScript
7 lines
233 B
TypeScript
import escapeRegExp from 'lib/escapeRegExp';
|
|
|
|
export default function highlightText(text: string, query: string) {
|
|
const regex = new RegExp('(' + escapeRegExp(query) + ')', 'gi');
|
|
return text.replace(regex, '<mark>$1</mark>');
|
|
}
|