本文整理汇总了Java中org.joni.Regex类的典型用法代码示例。如果您正苦于以下问题:Java Regex类的具体用法?Java Regex怎么用?Java Regex使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Regex类属于org.joni包,在下文中一共展示了Regex类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Grok
import org.joni.Regex; //导入依赖的package包/类
@SuppressWarnings("unchecked")
Grok(Map<String, String> patternBank, String grokPattern, boolean namedCaptures) {
this.patternBank = patternBank;
this.namedCaptures = namedCaptures;
this.expression = toRegex(grokPattern);
byte[] expressionBytes = expression.getBytes(StandardCharsets.UTF_8);
this.compiledExpression = new Regex(expressionBytes, 0, expressionBytes.length, Option.DEFAULT, UTF8Encoding.INSTANCE);
}
示例2: OnigRegExp
import org.joni.Regex; //导入依赖的package包/类
public OnigRegExp(String source) {
lastSearchStrUniqueId = null;
lastSearchPosition = -1;
lastSearchResult = null;
byte[] pattern = source.getBytes(StandardCharsets.UTF_8);
this.regex = new Regex(pattern, 0, pattern.length, Option.CAPTURE_GROUP, UTF8Encoding.INSTANCE, Syntax.DEFAULT,
WarnCallback.DEFAULT);
}
示例3: RegexpOpExp
import org.joni.Regex; //导入依赖的package包/类
public RegexpOpExp(ParserLiteral left, ParserLiteral right, int operator)
{
super(left, right, operator);
byte[] pattern = (((StringLiteral)right).val).getBytes(StandardCharsets.UTF_8);
this.regex = new Regex(pattern, 0, pattern.length, Option.NONE, UTF8Encoding.INSTANCE);
if (! left.isString()) {
throw new ConfigException(String.format("\"%s\" is not a String column", ((IdentifierLiteral)left).name));
}
}
示例4: getSingleModuleForPath
import org.joni.Regex; //导入依赖的package包/类
private List<Module> getSingleModuleForPath(File child) {
if(child.getName().endsWith(".rb")) {
try {
@SuppressWarnings("unchecked")
List<String> lines = FileUtils.readLines(child);
if(lines.size() > 1) {
String regex = lines.get(0);
regex = regex.substring(1, regex.length()).trim();
String triggers = lines.get(1);
triggers = triggers.substring(1, triggers.length()).trim();
String filename = child.getName();
String name = filename.substring(0, filename.length() - 3);
MewtwoMain.mewtwoLogger.info("Adding module " + name + " - regex = " + regex +
", triggers = "+ triggers);
Module m = new Module(
new Regex(regex.getBytes(), 0, regex.length(), Option.NONE, UTF8Encoding.INSTANCE),
Arrays.asList(triggers.split(",")), filename.substring(0, filename.length() - 3),
filename);
return Arrays.asList(m);
} else MewtwoMain.mewtwoLogger.info("Skipping file " + child.getAbsolutePath() + " - shorter than two lines!");
} catch (Throwable t) {
MewtwoMain.mewtwoLogger.error("Exception while parsing modules for " + child.getAbsolutePath() + "! ", t);
}
} else MewtwoMain.mewtwoLogger.info("Skipping file " + child.getAbsolutePath() + " - not a ruby file!");
return Arrays.asList();
}
示例5: generate
import org.joni.Regex; //导入依赖的package包/类
@Override
protected Regex generate(String i) {
byte[] pattern = getBytesUTF16LE(i);
return new Regex(pattern, 0, pattern.length, Option.NONE, UTF16LEEncoding.INSTANCE);
}
示例6: match
import org.joni.Regex; //导入依赖的package包/类
@Override
protected boolean match(Regex pattern, String searched) {
byte[] str = getBytesUTF16LE(searched);
Matcher matcher = pattern.matcher(str);
return matcher.search(0, str.length, Option.DEFAULT) != -1;
}
示例7: generate
import org.joni.Regex; //导入依赖的package包/类
@Override
protected Regex generate(String i) {
byte[] pattern = getBytesAscii(i);
return new Regex(pattern, 0, pattern.length, Option.NONE, ASCIIEncoding.INSTANCE);
}
示例8: match
import org.joni.Regex; //导入依赖的package包/类
@Override
protected boolean match(Regex pattern, String searched) {
byte[] str = getBytesAscii(searched);
Matcher matcher = pattern.matcher(str);
return matcher.search(0, str.length, Option.DEFAULT) != -1;
}
示例9: generate
import org.joni.Regex; //导入依赖的package包/类
@Override
protected Regex generate(String i) {
byte[] pattern = i.getBytes();
return new Regex(pattern, 0, pattern.length, Option.NONE, UTF8Encoding.INSTANCE);
}
示例10: match
import org.joni.Regex; //导入依赖的package包/类
@Override
protected boolean match(Regex pattern, String searched) {
byte[] str = searched.getBytes();
Matcher matcher = pattern.matcher(str);
return matcher.search(0, str.length, Option.DEFAULT) != -1;
}
示例11: JoniRegexEngine
import org.joni.Regex; //导入依赖的package包/类
public JoniRegexEngine(String regex, int flags) {
this.regex = regex;
byte[] b = Bytes.toBytes(regex);
this.pattern = new Regex(b, 0, b.length, patternToJoniFlags(flags), encoding, Syntax.Java);
}
示例12: Module
import org.joni.Regex; //导入依赖的package包/类
public Module(Regex regex, List<String> trigger, String name, String filename) {
this.regex = regex;
this.triggers = trigger;
this.name = name;
this.filename = filename;
}