本文整理了Java中org.joni.Matcher.search()
方法的一些代码示例,展示了Matcher.search()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Matcher.search()
方法的具体详情如下:
包路径:org.joni.Matcher
类名称:Matcher
方法名:search
暂无
代码示例来源:origin: apache/hbase
@Override
public int compareTo(byte[] value, int offset, int length) {
// Use subsequence match instead of full sequence match to adhere to the
// principle of least surprise.
Matcher m = pattern.matcher(value);
return m.search(offset, length, pattern.getOptions()) < 0 ? 1 : 0;
}
代码示例来源:origin: org.apache.hbase/hbase-client
@Override
public int compareTo(byte[] value, int offset, int length) {
// Use subsequence match instead of full sequence match to adhere to the
// principle of least surprise.
Matcher m = pattern.matcher(value);
return m.search(offset, length, pattern.getOptions()) < 0 ? 1 : 0;
}
代码示例来源:origin: apache/phoenix
int totalBytesNeeded = 0;
while (true) {
int nextCur = matcher.search(cur, srcRange, Option.DEFAULT);
if (nextCur < 0) {
totalBytesNeeded += srcRange - cur;
代码示例来源:origin: apache/phoenix
private boolean substr(byte[] srcBytes, int offset, int range, ImmutableBytesWritable outPtr) {
Matcher matcher = pattern.matcher(srcBytes, 0, range);
boolean ret = matcher.search(offset, range, Option.DEFAULT) >= 0;
if (ret) {
int len = matcher.getEnd() - matcher.getBegin();
outPtr.set(srcBytes, matcher.getBegin(), len);
} else {
outPtr.set(ByteUtil.EMPTY_BYTE_ARRAY);
}
return ret;
}
代码示例来源:origin: apache/phoenix
boolean append;
while (true) {
int nextCur = matcher.search(cur, srcRange, Option.DEFAULT);
if (nextCur < 0) {
builder.appendValue(srcBytes, cur, srcRange - cur);
代码示例来源:origin: apache/johnzon
@Override
public boolean test(final CharSequence string) {
return regex.matcher(string.toString().getBytes(StandardCharsets.UTF_8))
.search(0, string.length(), Option.NONE) > Matcher.FAILED;
}
代码示例来源:origin: org.jruby.joni/joni
protected void bench(String _reg, String _str, int warmup, int times) throws Exception {
byte[] reg = _reg.getBytes();
byte[] str = _str.getBytes();
Regex p = new Regex(reg,0,reg.length,Option.DEFAULT,ASCIIEncoding.INSTANCE,Syntax.DEFAULT);
System.err.println("::: /" + _reg + "/ =~ \"" + _str + "\", " + warmup + " * " + times + " times");
for(int j=0;j<warmup;j++) {
long before = System.currentTimeMillis();
for(int i = 0; i < times; i++) {
p.matcher(str, 0, str.length).search(0, str.length, Option.NONE);
}
long time = System.currentTimeMillis() - before;
System.err.println(": " + time + "ms");
}
}
代码示例来源:origin: jruby/joni
protected void bench(String _reg, String _str, int warmup, int times) throws Exception {
byte[] reg = _reg.getBytes();
byte[] str = _str.getBytes();
Regex p = new Regex(reg,0,reg.length,Option.DEFAULT,ASCIIEncoding.INSTANCE,Syntax.DEFAULT);
System.err.println("::: /" + _reg + "/ =~ \"" + _str + "\", " + warmup + " * " + times + " times");
for(int j=0;j<warmup;j++) {
long before = System.currentTimeMillis();
for(int i = 0; i < times; i++) {
p.matcher(str, 0, str.length).search(0, str.length, Option.NONE);
}
long time = System.currentTimeMillis() - before;
System.err.println(": " + time + "ms");
}
}
代码示例来源:origin: org.dynjs/dynjs
public Region match(String str, int from) {
byte[] strBytes = str.getBytes();
Matcher matcher = this.pattern.matcher(strBytes, 0, strBytes.length);
if (matcher.search(from, strBytes.length, 0) >= 0) {
return matcher.getEagerRegion();
}
return null;
}
代码示例来源:origin: jruby/joni
protected void benchBestOf(String _reg, String _str, int warmup, int times) throws Exception {
byte[] reg = _reg.getBytes();
byte[] str = _str.getBytes();
Regex p = new Regex(reg,0,reg.length,Option.DEFAULT,ASCIIEncoding.INSTANCE,Syntax.DEFAULT);
System.err.println("::: /" + _reg + "/ =~ \"" + _str + "\", " + warmup + " * " + times + " times");
long best = Long.MAX_VALUE;
for(int j=0;j<warmup;j++) {
long before = System.currentTimeMillis();
for(int i = 0; i < times; i++) {
p.matcher(str, 0, str.length).search(0, str.length, Option.NONE);
}
long time = System.currentTimeMillis() - before;
if(time < best) {
best = time;
}
System.err.print(".");
}
System.err.println(": " + best + "ms");
}
}
代码示例来源:origin: com.aliyun.hbase/alihbase-client
@Override
public int compareTo(byte[] value, int offset, int length) {
// Use subsequence match instead of full sequence match to adhere to the
// principle of least surprise.
Matcher m = pattern.matcher(value);
return m.search(offset, length, pattern.getOptions()) < 0 ? 1 : 0;
}
代码示例来源:origin: harbby/presto-connectors
@Override
public int compareTo(byte[] value, int offset, int length) {
// Use subsequence match instead of full sequence match to adhere to the
// principle of least surprise.
Matcher m = pattern.matcher(value);
return m.search(offset, length, pattern.getOptions()) < 0 ? 1 : 0;
}
代码示例来源:origin: anba/es6draft
@Override
public boolean find(int start) {
return update(matcher.search(byteIndex(start), byteLength, Option.NONE));
}
代码示例来源:origin: org.codelibs.elasticsearch.lib/grok
/**
* Checks whether a specific text matches the defined grok expression.
*
* @param text the string to match
* @return true if grok expression matches text, false otherwise.
*/
public boolean match(String text) {
Matcher matcher = compiledExpression.matcher(text.getBytes(StandardCharsets.UTF_8));
int result;
try {
threadWatchdog.register();
result = matcher.search(0, text.length(), Option.DEFAULT);
} finally {
threadWatchdog.unregister();
}
return (result != -1);
}
代码示例来源:origin: org.netbeans.api/org-jruby
private int performSearch(boolean reverse, int pos, ByteList value, Frame frame, Ruby runtime, ThreadContext context, RubyString str) {
check();
int realSize = value.realSize;
int begin = value.begin;
int range = reverse ? -pos : realSize - pos;
Matcher matcher = pattern.matcher(value.bytes, begin, begin + realSize);
int result = matcher.search(begin + pos, begin + pos + range, Option.NONE);
if (result < 0) {
frame.setBackRef(runtime.getNil());
return result;
}
updateBackRef(context, str, frame, matcher);
return result;
}
代码示例来源:origin: org.jruby/jruby-complete
public static int matcherSearch(ThreadContext context, Matcher matcher, int start, int range, int option) {
if (!context.runtime.getInstanceConfig().isInterruptibleRegexps()) return matcher.search(start, range, option);
try {
RubyThread thread = context.getThread();
SearchMatchTask task = new SearchMatchTask(thread, start, range, option, false);
return thread.executeTask(context, matcher, task);
} catch (InterruptedException e) {
throw context.runtime.newInterruptedRegexpError("Regexp Interrupted");
}
}
代码示例来源:origin: org.jruby/jruby-core
public static int matcherSearch(ThreadContext context, Matcher matcher, int start, int range, int option) {
if (!context.runtime.getInstanceConfig().isInterruptibleRegexps()) return matcher.search(start, range, option);
try {
RubyThread thread = context.getThread();
SearchMatchTask task = new SearchMatchTask(thread, start, range, option, false);
return thread.executeTask(context, matcher, task);
} catch (InterruptedException e) {
throw context.runtime.newInterruptedRegexpError("Regexp Interrupted");
}
}
代码示例来源:origin: com.aliyun.phoenix/ali-phoenix-core
private boolean substr(byte[] srcBytes, int offset, int range, ImmutableBytesWritable outPtr) {
Matcher matcher = pattern.matcher(srcBytes, 0, range);
boolean ret = matcher.search(offset, range, Option.DEFAULT) >= 0;
if (ret) {
int len = matcher.getEnd() - matcher.getBegin();
outPtr.set(srcBytes, matcher.getBegin(), len);
} else {
outPtr.set(ByteUtil.EMPTY_BYTE_ARRAY);
}
return ret;
}
代码示例来源:origin: org.apache.phoenix/phoenix-core
private boolean substr(byte[] srcBytes, int offset, int range, ImmutableBytesWritable outPtr) {
Matcher matcher = pattern.matcher(srcBytes, 0, range);
boolean ret = matcher.search(offset, range, Option.DEFAULT) >= 0;
if (ret) {
int len = matcher.getEnd() - matcher.getBegin();
outPtr.set(srcBytes, matcher.getBegin(), len);
} else {
outPtr.set(ByteUtil.EMPTY_BYTE_ARRAY);
}
return ret;
}
代码示例来源:origin: org.netbeans.api/org-jruby
private IRubyObject scanOnceNG(RubyRegexp regex, Matcher matcher, int range) {
if (matcher.search(matcher.value + value.begin, range, Option.NONE) >= 0) {
int end = matcher.getEnd();
if (matcher.getBegin() == end) {
if (value.realSize > end) {
matcher.value = end + regex.getPattern().getEncoding().length(value.bytes[value.begin + end]);
} else {
matcher.value = end + 1;
}
} else {
matcher.value = end;
}
return substr(matcher.getBegin(), end - matcher.getBegin()).infectBy(regex);
}
return null;
}
内容来源于网络,如有侵权,请联系作者删除!