github.com/elves/elvish@v0.15.0/pkg/strutil/subseq.go (about)

     1  package strutil
     2  
     3  import "strings"
     4  
     5  // HasSubseq determines whether s has t as its subsequence. A string t is a
     6  // subsequence of a string s if and only if there is a possible sequence of
     7  // steps of deleting characters from s that result in t.
     8  func HasSubseq(s, t string) bool {
     9  	for _, p := range t {
    10  		i := strings.IndexRune(s, p)
    11  		if i == -1 {
    12  			return false
    13  		}
    14  		s = s[i+len(string(p)):]
    15  	}
    16  	return true
    17  }