//普通匹配查找串的位置 public int SimpleIndex(StringList T, int pos = 1) { if (T.isEmpty() || this.isEmpty()) { return 0; } int mainLength = this.Length(); int matchLength = T.Length(); int i; if (pos > 0 && pos <= mainLength) { i = pos; while (i <= mainLength - matchLength + 1) { StringList sub = this.SubString(i, matchLength); if (sub.Compare(T) != 0) { i++; } else { return i; } } } return 0; }
一步步截取匹配长度的子串和匹配串对比。并不效率!