Ejemplo n.º 1
0
        public static List <int> FindAll_substrings(string ori, string sub, bool caseSensitive)
        {
            List <int> list = new List <int>();

            if (string.IsNullOrEmpty(ori) || string.IsNullOrEmpty(sub))
            {
                return(list);
            }

            for (int i = 0; i < ori.Length - sub.Length; ++i)
            {
                bool match = true;
                for (int j = 0; j < sub.Length; ++j)
                {
                    if (!HssStr.CharEqual(ori[i + j], sub[j], caseSensitive))
                    {
                        match = false;
                        break;
                    }
                }

                if (match)
                {
                    list.Add(i);
                    i += sub.Length - 1;
                }
            }

            return(list);
        }
Ejemplo n.º 2
0
        public void Get_wordHS()
        {
            if (string.IsNullOrEmpty(this.str))
            {
                return;
            }

            for (int i = 0; i < str.Length; ++i)
            {
                char c = str[i];

                if (HssStr.IsNum(c))
                {
                    this.sb.Append(c);
                }
                else if (HssStr.IsLetter(c))
                {
                    if (this.sb.Length > 0 && this.sb[0] == '-')
                    {
                        this.sb.Remove(0, 1);
                    }
                    this.sb.Append(c);
                    all_num_flag = false;
                }
                else if (c == '.')
                {
                    if (this.sb.Length > 0)
                    {
                        if (all_num_flag)
                        {
                            this.sb.Append(c);
                            if (this.dot_count > 1 && this.sb[0] == '-')
                            {
                                this.sb.Remove(0, 1);
                            }
                            ++this.dot_count;
                        }
                        else
                        {
                            this.Commit();
                        }
                    }
                }
                else if (c == '-')
                {
                    if (this.sb.Length < 1)
                    {
                        this.sb.Append(c);
                    }
                    else
                    {
                        this.Commit();
                    }
                }
                else
                {
                    this.Commit();
                }
            }

            this.Commit();
        }