Files
explore/lib/highlightText.ts
T
2022-12-28 12:36:41 +03:00

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>');
}