split.go 430 B

12345678910111213141516171819202122
  1. package gen
  2. import "regexp"
  3. func (g *defaultGenerator) split(source string) []string {
  4. reg := regexp.MustCompile(createTableFlag)
  5. index := reg.FindAllStringIndex(source, -1)
  6. list := make([]string, 0)
  7. for i := len(index) - 1; i >= 0; i-- {
  8. subIndex := index[i]
  9. if len(subIndex) == 0 {
  10. continue
  11. }
  12. start := subIndex[0]
  13. ddl := source[start:]
  14. list = append(list, ddl)
  15. source = source[:start]
  16. }
  17. return list
  18. }