MCPcopy Create free account
hub / github.com/experdot/pointer / createSearchPattern

Function createSearchPattern

src/renderer/src/utils/searchUtils.ts:26–41  ·  view source on GitHub ↗
(query: string, options: SearchOptions)

Source from the content-addressed store, hash-verified

24 * 根据搜索选项创建正则表达式
25 */
26export function createSearchPattern(query: string, options: SearchOptions): RegExp | null {
27 if (!query) return null
28
29 try {
30 let pattern = options.useRegex ? query : escapeRegExp(query)
31
32 if (options.matchWholeWord) {
33 pattern = `\\b${pattern}\\b`
34 }
35
36 return new RegExp(pattern, options.matchCase ? 'g' : 'gi')
37 } catch {
38 // 无效的正则表达式
39 return null
40 }
41}
42
43/**
44 * 在消息列表中查找所有匹配项

Callers 2

performGlobalSearchFunction · 0.90
findAllMatchesFunction · 0.85

Calls 1

escapeRegExpFunction · 0.70

Tested by

no test coverage detected