Exemplo n.º 1
0
        private IList <MatchItem> OnMatchs(char[] data, int length, bool matchFirst = false)
        {
            IList <MatchItem> result = new List <MatchItem>();
            Rule rule  = Rule1;
            int  index = 0;

            while (index < length)
            {
                CharGroup group = mGroup[Utils.Cast(data[index])];
                if (group != null)
                {
                    MatchItem item = group.Match(data, index);
                    if (item.IsMatch)
                    {
                        result.Add((MatchItem)item.Clone());
                        index           = item.EndIndex() + 1;
                        rule.mLastIndex = -10;
                        if (matchFirst)
                        {
                            return(result);
                        }
                    }
                    else
                    {
                        rule.Add(data, index);
                        index++;
                    }
                }
                else
                {
                    rule.Add(data, index);
                    index++;
                }
            }
            if (rule.Count > 2)
            {
                OnRule(data, rule, result);
            }
            return(result);
        }
Exemplo n.º 2
0
        private void Rule(MatchItem result, char[] data)
        {
            int      cindex = result.StartIndex();
            WordType ctype  = Utils.GetWordTypeWithChar(data[cindex]);

            if (ctype == WordType.EN || ctype == WordType.Number)
            {
                if (cindex > 1 && ctype == Utils.GetWordTypeWithChar(data[cindex - 1]))
                {
                    result.IsMatch = false;
                }
            }
            cindex = result.EndIndex();
            ctype  = Utils.GetWordTypeWithChar(data[cindex]);
            if (ctype == WordType.EN || ctype == WordType.Number)
            {
                if (cindex < data.Length - 1 && ctype == Utils.GetWordTypeWithChar(data[cindex + 1]))
                {
                    result.IsMatch = false;
                }
            }
        }