예제 #1
1
파일: Match.cs 프로젝트: hendryluk/nGrok
 public Match(string text, int offset, Grok grok, Regex regexp, System.Text.RegularExpressions.Match match)
 {
     Text = text;
     Offset = offset;
     Grok = grok;
     _regexp = regexp;
     _match = match;
 }
예제 #2
0
 public Match(string text, int offset, Grok grok, Regex regexp, System.Text.RegularExpressions.Match match)
 {
     Text    = text;
     Offset  = offset;
     Grok    = grok;
     _regexp = regexp;
     _match  = match;
 }
예제 #3
0
파일: Pile.cs 프로젝트: hendryluk/nGrok
        public void Compile(string pattern)
        {
            var grok = new Grok();
            foreach(var p in _patterns)
                grok.AddPattern(p.Key, p.Value);

            grok.Compile(pattern);
            Log.InfoFormat("Pile compiled new grok, pattern: {0}, expandedPattern = {1}", pattern, grok.ExpandedPattern);
            _groks.Add(grok);
        }
예제 #4
0
        public void Blah()
        {
            var grok = new Grok();
            grok.AddPattern("USERNAME", "[a-z]+");
            grok.AddPattern("HENLOG", "%{USERNAME:user};");

            grok.Compile("%{HENLOG:mylog}");
            var match = grok.Match("aaaaa;");
            match.Should().NotBeNull();

            var captures = match.Captures;
        }
예제 #5
0
        public void Compile(string pattern)
        {
            var grok = new Grok();

            foreach (var p in _patterns)
            {
                grok.AddPattern(p.Key, p.Value);
            }

            grok.Compile(pattern);
            Log.InfoFormat("Pile compiled new grok, pattern: {0}, expandedPattern = {1}", pattern, grok.ExpandedPattern);
            _groks.Add(grok);
        }
예제 #6
0
        private Capture GetCapture(string key, IEnumerable <Group> groups)
        {
            var    patternName = key = Grok.GetCaptureName(key) ?? key;
            string identifier  = null;

            var splits = key.Split(new[] { ':' }, 2);

            if (splits.Length > 1)
            {
                patternName = splits[0];
                identifier  = splits[1].Trim();
            }

            return(new Capture(patternName, identifier, groups.Where(g => g.Success).Select(g => g.Value).ToArray()));
        }