github.com/ladydascalie/elvish@v0.0.0-20170703214355-2964dd3ece7f/util/subseq.go (about) 1 package util 2 3 import "unicode/utf8" 4 5 func HasSubseq(s, t string) bool { 6 i, j := 0, 0 7 for i < len(s) && j < len(t) { 8 s0, di := utf8.DecodeRuneInString(s[i:]) 9 t0, dj := utf8.DecodeRuneInString(t[j:]) 10 i += di 11 if s0 == t0 { 12 j += dj 13 } 14 } 15 return j == len(t) 16 }