本文整理了Java中org.joni.Regex.numberOfCaptures
方法的一些代码示例,展示了Regex.numberOfCaptures
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Regex.numberOfCaptures
方法的具体详情如下:
包路径:org.joni.Regex
类名称:Regex
方法名:numberOfCaptures
暂无
代码示例来源:origin: net.thisptr/jackson-jq
private static String[] names(final Regex regex) {
final String[] names = new String[regex.numberOfCaptures() + 1];
if (regex.numberOfNames() == 0)
return names;
for (final Iterator<NameEntry> iter = regex.namedBackrefIterator(); iter.hasNext();) {
final NameEntry backref = iter.next();
final String name = new String(backref.name, backref.nameP, backref.nameEnd - backref.nameP, StandardCharsets.UTF_8);
for (final int index : backref.getBackRefs()) {
names[index] = name;
}
}
return names;
}
}
代码示例来源:origin: eiiches/jackson-jq
private static String[] names(final Regex regex) {
final String[] names = new String[regex.numberOfCaptures() + 1];
if (regex.numberOfNames() == 0)
return names;
for (final Iterator<NameEntry> iter = regex.namedBackrefIterator(); iter.hasNext();) {
final NameEntry backref = iter.next();
final String name = new String(backref.name, backref.nameP, backref.nameEnd - backref.nameP, StandardCharsets.UTF_8);
for (final int index : backref.getBackRefs()) {
names[index] = name;
}
}
return names;
}
}
代码示例来源:origin: fbacchella/LogHub
@Override
public boolean configure(Properties properties) {
try {
// Generate pattern using both ASCII and UTF-8
byte[] patternSrcBytesAscii = getBytesAscii(patternSrc);
// the ascii pattern is generated only if the source pattern is pure ASCII
if (patternSrcBytesAscii != null) {
patternAscii = new Regex(patternSrcBytesAscii, 0, patternSrcBytesAscii.length, Option.NONE, USASCIIEncoding.INSTANCE);
} else {
patternAscii = null;
}
byte[] patternSrcBytesUtf8 = patternSrc.getBytes(StandardCharsets.UTF_8);
patternUtf8 = new Regex(patternSrcBytesUtf8, 0, patternSrcBytesUtf8.length, Option.NONE, UTF8Encoding.INSTANCE);
if (patternUtf8.numberOfCaptures() != patternUtf8.numberOfNames()) {
logger.error("Can't have two captures with same name");
return false;
} else {
return super.configure(properties);
}
} catch (SyntaxException e) {
logger.error("Error parsing regex:" + Helpers.resolveThrowableException(e));
logger.catching(Level.DEBUG, e);
return false;
}
}
代码示例来源:origin: org.netbeans.api/org-jruby
RubyMatchData match = rubyRegex.updateBackRef(context, this, frame, matcher);
match.use();
if (regex.numberOfCaptures() == 0) {
repl = objAsString(context, block.yield(context, substr(matcher.getBegin(), matcher.getEnd() - matcher.getBegin())));
} else {
if (regex.numberOfCaptures() == 0) {
beg = matcher.getBegin();
plen = matcher.getEnd() - beg;
代码示例来源:origin: org.netbeans.api/org-jruby
RubyArray ary = runtime.newArray();
if (regex.numberOfCaptures() == 0) {
while ((result = scanOnceNG(rubyRegex, matcher, range)) != null) ary.append(result);
} else {
RubyMatchData match = null;
if (regex.numberOfCaptures() == 0) {
while ((result = scanOnceNG(rubyRegex, matcher, range)) != null) {
match = rubyRegex.updateBackRef(context, this, frame, matcher);
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
private IRubyObject scanNoIter(ThreadContext context, Regex pattern, Matcher matcher, Encoding enc, int begin, int range, int tuFlags) {
Ruby runtime = context.runtime;
RubyArray ary = runtime.newArray();
int end = 0;
if (pattern.numberOfCaptures() == 0) {
while (RubyRegexp.matcherSearch(runtime, matcher, begin + end, range, Option.NONE) >= 0) {
end = positionEnd(matcher, enc, begin, range);
RubyString substr = makeShared(runtime, matcher.getBegin(), matcher.getEnd() - matcher.getBegin());
substr.infectBy(tuFlags);
ary.append(substr);
}
} else {
while (RubyRegexp.matcherSearch(runtime, matcher, begin + end, range, Option.NONE) >= 0) {
end = positionEnd(matcher, enc, begin, range);
ary.append(populateCapturesForScan(runtime, matcher, range, tuFlags, false));
}
}
if (ary.size() > 0) {
RubyMatchData match = RubyRegexp.createMatchData(context, this, matcher, pattern);
match.infectBy(tuFlags);
context.setBackRef(match);
} else {
context.setBackRef(runtime.getNil());
}
return ary;
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
private IRubyObject scanNoIter(ThreadContext context, Regex pattern, Matcher matcher, Encoding enc, int begin, int range, int tuFlags) {
Ruby runtime = context.runtime;
RubyArray ary = runtime.newArray();
int end = 0;
if (pattern.numberOfCaptures() == 0) {
while (RubyRegexp.matcherSearch(runtime, matcher, begin + end, range, Option.NONE) >= 0) {
end = positionEnd(matcher, enc, begin, range);
RubyString substr = makeShared(runtime, matcher.getBegin(), matcher.getEnd() - matcher.getBegin());
substr.infectBy(tuFlags);
ary.append(substr);
}
} else {
while (RubyRegexp.matcherSearch(runtime, matcher, begin + end, range, Option.NONE) >= 0) {
end = positionEnd(matcher, enc, begin, range);
ary.append(populateCapturesForScan(runtime, matcher, range, tuFlags, false));
}
}
if (ary.size() > 0) {
RubyMatchData match = RubyRegexp.createMatchData(context, this, matcher, pattern);
match.infectBy(tuFlags);
context.setBackRef(match);
} else {
context.setBackRef(runtime.getNil());
}
return ary;
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
if (pattern.numberOfCaptures() == 0) {
while (RubyRegexp.matcherSearch(runtime, matcher, begin + end, range, Option.NONE) >= 0) {
end = positionEnd(matcher, enc, begin, range);
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
if (pattern.numberOfCaptures() == 0) {
while (RubyRegexp.matcherSearch(runtime, matcher, begin + end, range, Option.NONE) >= 0) {
end = positionEnd(matcher, enc, begin, range);
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
private IRubyObject scanIter(ThreadContext context, Regex pattern, Matcher matcher, Encoding enc, Block block, int begin, int range, int tuFlags) {
Ruby runtime = context.runtime;
byte[]bytes = value.getUnsafeBytes();
int size = value.getRealSize();
RubyMatchData match = null;
int end = 0;
if (pattern.numberOfCaptures() == 0) {
while (RubyRegexp.matcherSearch(runtime, matcher, begin + end, range, Option.NONE) >= 0) {
end = positionEnd(matcher, enc, begin, range);
match = RubyRegexp.createMatchData(context, this, matcher, pattern);
RubyString substr = makeShared(runtime, matcher.getBegin(), matcher.getEnd() - matcher.getBegin());
substr.infectBy(tuFlags);
match.infectBy(tuFlags);
context.setBackRef(match);
block.yield(context, substr);
modifyCheck(bytes, size);
}
} else {
while (RubyRegexp.matcherSearch(runtime, matcher, begin + end, range, Option.NONE) >= 0) {
end = positionEnd(matcher, enc, begin, range);
match = RubyRegexp.createMatchData(context, this, matcher, pattern);
match.infectBy(tuFlags);
context.setBackRef(match);
block.yield(context, populateCapturesForScan(runtime, matcher, range, tuFlags, false));
modifyCheck(bytes, size);
}
}
context.setBackRef(match == null ? runtime.getNil() : match);
return this;
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
private IRubyObject scanIter(ThreadContext context, Regex pattern, Matcher matcher, Encoding enc, Block block, int begin, int range, int tuFlags) {
Ruby runtime = context.runtime;
byte[]bytes = value.getUnsafeBytes();
int size = value.getRealSize();
RubyMatchData match = null;
int end = 0;
if (pattern.numberOfCaptures() == 0) {
while (RubyRegexp.matcherSearch(runtime, matcher, begin + end, range, Option.NONE) >= 0) {
end = positionEnd(matcher, enc, begin, range);
match = RubyRegexp.createMatchData(context, this, matcher, pattern);
RubyString substr = makeShared(runtime, matcher.getBegin(), matcher.getEnd() - matcher.getBegin());
substr.infectBy(tuFlags);
match.infectBy(tuFlags);
context.setBackRef(match);
block.yield(context, substr);
modifyCheck(bytes, size);
}
} else {
while (RubyRegexp.matcherSearch(runtime, matcher, begin + end, range, Option.NONE) >= 0) {
end = positionEnd(matcher, enc, begin, range);
match = RubyRegexp.createMatchData(context, this, matcher, pattern);
match.infectBy(tuFlags);
context.setBackRef(match);
block.yield(context, populateCapturesForScan(runtime, matcher, range, tuFlags, false));
modifyCheck(bytes, size);
}
}
context.setBackRef(match == null ? runtime.getNil() : match);
return this;
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
if (pattern.numberOfCaptures() == 0) {
while (RubyRegexp.matcherSearch(runtime, matcher, begin + end, range, Option.NONE) >= 0) {
end = positionEnd(matcher, enc, begin, range);
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
boolean captures = pattern.numberOfCaptures() != 0;
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
boolean captures = pattern.numberOfCaptures() != 0;
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
if (pattern.numberOfCaptures() == 0) {
while (RubyRegexp.matcherSearch(runtime, matcher, begin + end, range, Option.NONE) >= 0) {
end = positionEnd(matcher, enc, begin, range);
代码示例来源:origin: org.jruby/jruby-complete
boolean captures = pattern.getPattern().numberOfCaptures() != 0;
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
Encoding enc = getEncodingForKCodeDefault(runtime, pattern, pat);
boolean captures = pattern.numberOfCaptures() != 0;
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
Encoding enc = getEncodingForKCodeDefault(runtime, pattern, pat);
boolean captures = pattern.numberOfCaptures() != 0;
代码示例来源:origin: org.jruby/jruby-core
boolean captures = pattern.getPattern().numberOfCaptures() != 0;
代码示例来源:origin: org.netbeans.api/org-jruby
if (regex.numberOfCaptures() == 0) { // shorter path, no captures defined, no region will be returned
while ((end = matcher.search(start, range, Option.NONE)) >= 0) {
if (start == end + begin && matcher.getBegin() == matcher.getEnd()) {
内容来源于网络,如有侵权,请联系作者删除!