本文整理了Java中io.krakens.grok.api.Grok.getNamedRegex()
方法的一些代码示例,展示了Grok.getNamedRegex()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Grok.getNamedRegex()
方法的具体详情如下:
包路径:io.krakens.grok.api.Grok
类名称:Grok
方法名:getNamedRegex
[英]Get the named regex from the Grok pattern.
[中]从Grok模式中获取命名的正则表达式。
代码示例来源:origin: thekrakken/java-grok
public int compare(Grok g1, Grok g2) {
return (this.complexity(g1.getNamedRegex()) < this.complexity(g2.getNamedRegex())) ? 1 : 0;
}
代码示例来源:origin: vmware/hillview
Set<String> groups = GrokUtils.getNameGroups(grok.getNamedRegex());
for (String s : groups) {
String name = grok.getNamedRegexCollectionById(s);
代码示例来源:origin: io.krakens/java-grok
public int compare(Grok g1, Grok g2) {
return (this.complexity(g1.getNamedRegex()) < this.complexity(g2.getNamedRegex())) ? 1 : 0;
}
代码示例来源:origin: thekrakken/java-grok
if (this.complexity(value.getNamedRegex()) < 20) {
continue;
代码示例来源:origin: io.krakens/java-grok
if (this.complexity(value.getNamedRegex()) < 20) {
continue;
代码示例来源:origin: thekrakken/java-grok
@Test
public void test006_testLoadPatternFromFileIso_8859_1() throws IOException, GrokException {
File temp = tempFolder.newFile("grok-tmp-pattern");
try (FileOutputStream fis = new FileOutputStream(temp);
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fis, StandardCharsets.ISO_8859_1))) {
bw.write("TEST §");
}
GrokCompiler compiler = GrokCompiler.newInstance();
compiler.register(new FileInputStream(temp), StandardCharsets.ISO_8859_1);
Grok grok = compiler.compile("%{TEST}");
assertEquals("(?<name0>§)", grok.getNamedRegex());
}
代码示例来源:origin: thekrakken/java-grok
@Test
public void test005_testLoadPatternFromFile() throws IOException, GrokException {
File temp = tempFolder.newFile("grok-tmp-pattern");
try (BufferedWriter bw = new BufferedWriter(new FileWriter(temp))) {
bw.write("TEST \\d+");
}
GrokCompiler compiler = GrokCompiler.newInstance();
compiler.register(new FileInputStream(temp));
Grok grok = compiler.compile("%{TEST}");
assertEquals("(?<name0>\\d+)", grok.getNamedRegex());
}
代码示例来源:origin: thekrakken/java-grok
@Test
public void test007_testLoadPatternFromReader() throws IOException, GrokException {
Reader reader = new StringReader("TEST €");
GrokCompiler compiler = GrokCompiler.newInstance();
compiler.register(reader);
Grok grok = compiler.compile("%{TEST}");
assertEquals("(?<name0>€)", grok.getNamedRegex());
}
代码示例来源:origin: thekrakken/java-grok
@Test
public void test004_sameExpantedPatern() throws GrokException {
compiler.register("test", "hello world");
Grok grok = compiler.compile("%{test}");
assertEquals("(?<name0>hello world)", grok.getNamedRegex());
}
代码示例来源:origin: thekrakken/java-grok
@Test
public void test001_captureMathod() {
compiler.register("foo", ".*");
Grok grok = compiler.compile("%{foo}");
Match match = grok.match("Hello World");
assertEquals("(?<name0>.*)", grok.getNamedRegex());
assertEquals("Hello World", match.getSubject());
Map<String, Object> map = match.capture();
assertEquals(1, map.size());
assertEquals("Hello World", map.get("foo"));
assertEquals("{foo=Hello World}", map.toString());
}
代码示例来源:origin: thekrakken/java-grok
@Test
public void test002_captureMathodMulti() throws GrokException {
compiler.register("foo", ".*");
compiler.register("bar", ".*");
Grok grok = compiler.compile("%{foo} %{bar}");
Match match = grok.match("Hello World");
assertEquals("(?<name0>.*) (?<name1>.*)", grok.getNamedRegex());
assertEquals("Hello World", match.getSubject());
Map<String, Object> map = match.capture();
assertEquals(2, map.size());
assertEquals("Hello", map.get("foo"));
assertEquals("World", map.get("bar"));
assertEquals("{foo=Hello, bar=World}", map.toString());
}
代码示例来源:origin: thekrakken/java-grok
@Test
public void test003_captureMathodNasted() throws GrokException {
compiler.register("foo", "\\w+ %{bar}");
compiler.register("bar", "\\w+");
Grok grok = compiler.compile("%{foo}");
Match match = grok.match("Hello World");
assertEquals("(?<name0>\\w+ (?<name1>\\w+))", grok.getNamedRegex());
assertEquals("Hello World", match.getSubject());
Map<String, Object> map = match.capture();
assertEquals(2, map.size());
assertEquals("Hello World", map.get("foo"));
assertEquals("World", map.get("bar"));
assertEquals("{foo=Hello World, bar=World}", map.toString());
}
内容来源于网络,如有侵权,请联系作者删除!