func literalPrefix(s *syntax.Regexp) string {
	for s != nil && s.Op == syntax.OpConcat {
		if len(s.Sub) < 1 {
			return ""
		}
		s = s.Sub[0]
	}
	if s.Op == syntax.OpLiteral && (s.Flags&syntax.FoldCase == 0) {
		return string(s.Rune)
	}
	return ""  
}
Returns the literal prefix given the parse tree for a regexp
package scorch
import (
	"regexp/syntax"
	"github.com/blevesearch/vellum/regexp"
)
func parseRegexp(pattern string) (a *regexp.Regexp, prefixBeg, prefixEnd []byte, err error) {
	parsed, err := syntax.Parse(pattern, syntax.Perl)
	if err != nil {
		return nil, nil, nil, err
	}
	re, err := regexp.NewParsedWithLimit(pattern, parsed, regexp.DefaultLimit)
	if err != nil {
		return nil, nil, nil, err
	}
	prefix := literalPrefix(parsed)
	if prefix != "" {
		prefixBeg := []byte(prefix)
		prefixEnd := calculateExclusiveEndFromPrefix(prefixBeg)
		return re, prefixBeg, prefixEnd, nil
	}
	return re, nil, nil, nil
}