params.go 469 B

12345678910111213141516171819202122
  1. package arango
  2. import (
  3. "regexp"
  4. )
  5. // https://docs.arangodb.com/3.11/aql/fundamentals/bind-parameters/#syntax
  6. var paramRegexp = regexp.MustCompile("@(@?[A-z0-9_]+)")
  7. // ReadParams reads out named parameters from an AQL string.
  8. func ReadParams(input string) []string {
  9. params := []string{}
  10. matches := paramRegexp.FindAllStringSubmatch(input, -1)
  11. if matches != nil {
  12. for _, match := range matches {
  13. params = append(params, match[1])
  14. }
  15. }
  16. return params
  17. }