MCPcopy
hub / github.com/monochromegane/the_platinum_searcher / newPattern

Function newPattern

pattern.go:12–29  ·  view source on GitHub ↗
(p string, opts Option)

Source from the content-addressed store, hash-verified

10}
11
12func newPattern(p string, opts Option) (pattern, error) {
13 pattern := pattern{pattern: []byte(p), opts: opts}
14
15 if opts.SearchOption.Regexp {
16 var reg *regexp.Regexp
17 var err error
18 if opts.SearchOption.IgnoreCase {
19 reg, err = regexp.Compile(`(?i)(` + p + `)`)
20 } else {
21 reg, err = regexp.Compile(`(` + p + `)`)
22 }
23 if err != nil {
24 return pattern, err
25 }
26 pattern.regexp = reg
27 }
28 return pattern, nil
29}

Callers 13

ExampleFormatEnableGroupFunction · 0.85
ExampleFormatNoGroupFunction · 0.85
ExampleFormatMatchLineFunction · 0.85
startMethod · 0.85
TestFixedGrepFunction · 0.85
TestFixedGrepLargeFileFunction · 0.85
TestExtendedGrepFunction · 0.85

Calls

no outgoing calls

Tested by 12

ExampleFormatEnableGroupFunction · 0.68
ExampleFormatNoGroupFunction · 0.68
ExampleFormatMatchLineFunction · 0.68
TestFixedGrepFunction · 0.68
TestFixedGrepLargeFileFunction · 0.68
TestExtendedGrepFunction · 0.68
TestStdinGrepFunction · 0.68