本文整理了Java中java.util.regex.Matcher.region()
方法的一些代码示例,展示了Matcher.region()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Matcher.region()
方法的具体详情如下:
包路径:java.util.regex.Matcher
类名称:Matcher
方法名:region
[英]Resets this matcher and sets a region. Only characters inside the region are considered for a match.
[中]重置此匹配器并设置区域。仅考虑区域内的字符进行匹配。
代码示例来源:origin: osmandapp/Osmand
/**
* Skip over any whitespace so that the matcher region starts at the next
* token.
*/
private void skipWhitespace() {
matcher.usePattern(WHITESPACE);
if (matcher.lookingAt()) {
matcher.region(matcher.end(), matcher.regionEnd());
}
}
代码示例来源:origin: robovm/robovm
private boolean setHeadTokenRegion(int findIndex) {
int tokenStartIndex;
int tokenEndIndex;
boolean setSuccess = false;
// If no delimiter exists, but something exists in this scanner
if (findIndex == -1 && preStartIndex != bufferLength) {
tokenStartIndex = preStartIndex;
tokenEndIndex = bufferLength;
findStartIndex = bufferLength;
matcher.region(tokenStartIndex, tokenEndIndex);
setSuccess = true;
}
// If the first delimiter of scanner is not at the find start position
if (-1 != findIndex && preStartIndex != matcher.start()) {
tokenStartIndex = preStartIndex;
tokenEndIndex = matcher.start();
findStartIndex = matcher.start();
// set match region and return
matcher.region(tokenStartIndex, tokenEndIndex);
setSuccess = true;
}
return setSuccess;
}
代码示例来源:origin: com.google.protobuf/protobuf-java
if (matcher.lookingAt()) {
currentToken = matcher.group();
matcher.region(matcher.end(), matcher.regionEnd());
} else {
matcher.region(pos + 1, matcher.regionEnd());
代码示例来源:origin: aragozin/jvm-tools
matcher.region(matcher.end(), text.length());
代码示例来源:origin: square/okhttp
Matcher parameter = PARAMETER.matcher(string);
for (int s = typeSubtype.end(); s < string.length(); s = parameter.end()) {
parameter.region(s, string.length());
if (!parameter.lookingAt()) {
throw new IllegalArgumentException("Parameter is not formatted correctly: \""
代码示例来源:origin: osmandapp/Osmand
if (matcher.lookingAt()) {
currentToken = matcher.group();
matcher.region(matcher.end(), matcher.regionEnd());
} else {
matcher.region(pos + 1, matcher.regionEnd());
代码示例来源:origin: com.google.protobuf/protobuf-java
/**
* Skip over any whitespace so that the matcher region starts at the next
* token.
*/
private void skipWhitespace() {
matcher.usePattern(WHITESPACE);
if (matcher.lookingAt()) {
matcher.region(matcher.end(), matcher.regionEnd());
}
}
代码示例来源:origin: atlassian/commonmark-java
/**
* If RE matches at current index in the input, advance index and return the match; otherwise return null.
*/
private String match(Pattern re) {
if (index >= input.length()) {
return null;
}
Matcher matcher = re.matcher(input);
matcher.region(index, input.length());
boolean m = matcher.find();
if (m) {
index = matcher.end();
return matcher.group();
} else {
return null;
}
}
代码示例来源:origin: ltsopensource/light-task-scheduler
Strategy currentStrategy = getStrategy(currentFormatField, definingCalendar);
for (; ; ) {
patternMatcher.region(patternMatcher.end(), patternMatcher.regionEnd());
if (!patternMatcher.lookingAt()) {
nextStrategy = null;
代码示例来源:origin: square/okhttp
matcher.region(pos, end);
代码示例来源:origin: ltsopensource/light-task-scheduler
Strategy currentStrategy = getStrategy(currentFormatField, definingCalendar);
for (; ; ) {
patternMatcher.region(patternMatcher.end(), patternMatcher.regionEnd());
if (!patternMatcher.lookingAt()) {
nextStrategy = null;
代码示例来源:origin: prestodb/presto
Matcher parameter = PARAMETER.matcher(string);
for (int s = typeSubtype.end(); s < string.length(); s = parameter.end()) {
parameter.region(s, string.length());
if (!parameter.lookingAt()) return null; // This is not a well-formed media type.
代码示例来源:origin: robovm/robovm
private void resetMatcher() {
if (matcher == null) {
matcher = delimiter.matcher(buffer);
} else {
matcher.reset(buffer);
}
matcher.useTransparentBounds(true);
matcher.useAnchoringBounds(false);
matcher.region(findStartIndex, bufferLength);
}
代码示例来源:origin: stanfordnlp/CoreNLP
Matcher matcher = pattern.matcher(text);
List<IntPair> offsets = null;
matcher.region(start,end);
int i = (matcher.find())? matcher.start():-1;
if (i >= 0 && i < end) { offsets = new ArrayList<>(); }
代码示例来源:origin: prestodb/presto
matcher.region(pos, end);
代码示例来源:origin: hibernate/hibernate-orm
matcher.region( fromIndex, matchString.length() );
代码示例来源:origin: com.squareup.okhttp3/okhttp
Matcher parameter = PARAMETER.matcher(string);
for (int s = typeSubtype.end(); s < string.length(); s = parameter.end()) {
parameter.region(s, string.length());
if (!parameter.lookingAt()) {
throw new IllegalArgumentException("Parameter is not formatted correctly: \""
代码示例来源:origin: com.squareup.okhttp3/okhttp
matcher.region(pos, end);
代码示例来源:origin: robovm/robovm
private boolean setTokenRegion() {
// The position where token begins
int tokenStartIndex = 0;
// The position where token ends
int tokenEndIndex = 0;
// Use delimiter pattern
matcher.usePattern(delimiter);
matcher.region(findStartIndex, bufferLength);
tokenStartIndex = findPreDelimiter();
if (setHeadTokenRegion(tokenStartIndex)) {
return true;
}
tokenEndIndex = findDelimiterAfter();
// If the second delimiter is not found
if (tokenEndIndex == -1) {
// Just first Delimiter Exists
if (findStartIndex == bufferLength) {
return false;
}
tokenEndIndex = bufferLength;
findStartIndex = bufferLength;
}
matcher.region(tokenStartIndex, tokenEndIndex);
return true;
}
代码示例来源:origin: jphp-group/jphp
@Signature({
@Arg("start"),
@Arg("end")
})
public Memory region(Environment env, Memory... args) {
matcher.region(args[0].toInteger(), args[1].toInteger());
return new ObjectMemory(this);
}
内容来源于网络,如有侵权,请联系作者删除!