()
| 18 | var endsWithBracketExp = regexp.MustCompile(`\[([^\]]+)\]$`) |
| 19 | |
| 20 | func (p *OpPath) getChildName() string { |
| 21 | path := string(*p) |
| 22 | if path == "$" || path == "." { |
| 23 | return "" |
| 24 | } |
| 25 | |
| 26 | if endsWithBracketExp.MatchString(path) { |
| 27 | matches := endsWithBracketExp.FindStringSubmatch(path) |
| 28 | if len(matches) > 0 { |
| 29 | match := matches[1] |
| 30 | match = strings.ReplaceAll(match, `'`, "") |
| 31 | match = strings.ReplaceAll(match, `"`, "") |
| 32 | return match |
| 33 | } |
| 34 | return "" |
| 35 | } |
| 36 | |
| 37 | tokens := regexp.MustCompile(`\$|\.`).Split(path, -1) |
| 38 | if len(tokens) == 0 { |
| 39 | return "" |
| 40 | } |
| 41 | |
| 42 | return tokens[len(tokens)-1] |
| 43 | } |
| 44 | |
| 45 | func (p *OpPath) getParentPath() string { |
| 46 | path := string(*p) |
no outgoing calls