Пример #1
0
        private static List<string> GetNodeRegexOccurrences(FCS.Lite.Base.IAbstractTextNode textNode, string regex)
        {
            List<string> matches = new List<string>();

            FCS.Lite.Regex currentExpression = new FCS.Lite.Regex(regex, true);
            
            for (int i = 0; i < textNode.GetInfoCount(); ++i)
            {
                FCS.Lite.Base.NodeInfo nodeInfo = textNode.GetInfo(i);

                System.Collections.ArrayList matchList = currentExpression.Matches(nodeInfo.value);

                for (int j = 0; j < matchList.Count; ++j)
                {
                    string currentMatch = matchList[j] as string;
                    if (string.IsNullOrEmpty(currentMatch))
                        continue;

                    if (currentMatch.Length == 0)
                        matches.Add(nodeInfo.value);
                    else
                        matches.Add(currentMatch);
                }
            }

            return matches;
        }
Пример #2
0
        private static List<string> GetNodeOccurrences(FCS.Lite.Base.IAbstractTextNode textNode, string[] searchContent)
        {
            List<string> matches = new List<string>();

            for (int i = 0; i < textNode.GetInfoCount(); ++i)
            {
                FCS.Lite.Base.NodeInfo nodeInfo = textNode.GetInfo(i);

                // Look for the content in the nodeInfo
                for(int j = 0; j < searchContent.Length; ++j)
                {
                    string val = nodeInfo.value;

                    int pos = -1;
                    do
                    {
                        pos = val.IndexOf(searchContent[j], pos + 1);
                        
                        if(pos != -1)
                            matches.Add(nodeInfo.value);
                    }
                    while (pos != -1);
                }
            }
            return matches;
        }