MCPcopy Create free account
hub / github.com/every-app/sam / createKeywordPattern

Function createKeywordPattern

lib/analyzers/keyword.mjs:52–55  ·  view source on GitHub ↗
(keyword, flags)

Source from the content-addressed store, hash-verified

50}
51
52function createKeywordPattern(keyword, flags) {
53 const escapedKeyword = escapeRegex(keyword).replace(/\s+/g, "\\s+");
54 return new RegExp(`(^|[^A-Za-z0-9])${escapedKeyword}(?=$|[^A-Za-z0-9])`, flags);
55}
56
57function escapeRegex(value) {
58 return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");

Callers 2

countOccurrencesFunction · 0.85
containsKeywordFunction · 0.85

Calls 1

escapeRegexFunction · 0.70

Tested by

no test coverage detected