MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / buildRegex

Function buildRegex

console/src/components/Highlight.tsx:33–42  ·  view source on GitHub ↗
(query: string[], caseSensitive: boolean)

Source from the content-addressed store, hash-verified

31}
32
33function buildRegex(query: string[], caseSensitive: boolean) {
34 const _query = query
35 .filter((text) => text.length !== 0)
36 .map((text) => escapeRegExp(text.trim()));
37 if (!_query.length) {
38 return null;
39 }
40
41 return new RegExp(`(${_query.join("|")})`, `${caseSensitive ? "" : "i"}g`);
42}
43
44interface HighlightOptions {
45 text: string;

Callers 1

highlightWordsFunction · 0.85

Calls 5

escapeRegExpFunction · 0.90
mapMethod · 0.45
filterMethod · 0.45
trimMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected