MCPcopy Index your code
hub / github.com/google/codesearch / Compile

Function Compile

regexp/regexp.go:30–51  ·  view source on GitHub ↗

Compile parses a regular expression and returns, if successful, a Regexp object that can be used to match against lines of text.

(expr string)

Source from the content-addressed store, hash-verified

28// Compile parses a regular expression and returns, if successful,
29// a Regexp object that can be used to match against lines of text.
30func Compile(expr string) (*Regexp, error) {
31 re, err := syntax.Parse(expr, syntax.Perl)
32 if err != nil {
33 return nil, err
34 }
35 sre := re.Simplify()
36 prog, err := syntax.Compile(sre)
37 if err != nil {
38 return nil, err
39 }
40 if err := toByteProg(prog); err != nil {
41 return nil, err
42 }
43 r := &Regexp{
44 Syntax: re,
45 expr: expr,
46 }
47 if err := r.m.init(prog); err != nil {
48 return nil, err
49 }
50 return r, nil
51}
52
53func (r *Regexp) Match(b []byte, beginText, endText bool) (end int) {
54 return r.m.match(b, beginText, endText)

Callers 4

mainFunction · 0.92
MainFunction · 0.92
TestMatchFunction · 0.85
TestGrepFunction · 0.85

Calls 2

toByteProgFunction · 0.85
initMethod · 0.45

Tested by 2

TestMatchFunction · 0.68
TestGrepFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…