MCPcopy Create free account
hub / github.com/dgraph-io/dgraph / parseRegexArgs

Function parseRegexArgs

dql/parser.go:1715–1733  ·  view source on GitHub ↗
(val string)

Source from the content-addressed store, hash-verified

1713}
1714
1715func parseRegexArgs(val string) (regexArgs, error) {
1716 // it is possible that val comes in a variable and has not been validated yet.
1717 // we do the validation here and ensure that it looks like: /<expr>/.
1718 if len(val) == 0 {
1719 return regexArgs{}, errors.Errorf("Found empty regex: [%s]", val)
1720 }
1721 end := strings.LastIndex(val, "/")
1722 if end < 1 || val[0] != '/' {
1723 return regexArgs{}, errors.Errorf("Found invalid regex: [%s]", val)
1724 }
1725
1726 expr := strings.Replace(val[1:end], "\\/", "/", -1)
1727 flags := ""
1728 if end+1 < len(val) {
1729 flags = val[end+1:]
1730 }
1731
1732 return regexArgs{expr, flags}, nil
1733}
1734
1735func parseFunction(it *lex.ItemIterator, gq *GraphQuery) (*Function, error) {
1736 function := &Function{}

Callers 2

regExpVariableFilterFunction · 0.85
parseFunctionFunction · 0.85

Calls 2

ErrorfMethod · 0.45
LastIndexMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…