本文整理汇总了Java中jdk.nashorn.internal.runtime.regexp.RegExpResult.getIndex方法的典型用法代码示例。如果您正苦于以下问题:Java RegExpResult.getIndex方法的具体用法?Java RegExpResult.getIndex怎么用?Java RegExpResult.getIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jdk.nashorn.internal.runtime.regexp.RegExpResult
的用法示例。
在下文中一共展示了RegExpResult.getIndex方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: NativeRegExpExecResult
import jdk.nashorn.internal.runtime.regexp.RegExpResult; //导入方法依赖的package包/类
NativeRegExpExecResult(final RegExpResult result, final Global global) {
super(global.getArrayPrototype(), $nasgenmap$);
setIsArray();
this.setArray(ArrayData.allocate(result.getGroups().clone()));
this.index = result.getIndex();
this.input = result.getInput();
}
示例2: search
import jdk.nashorn.internal.runtime.regexp.RegExpResult; //导入方法依赖的package包/类
/**
* Tests for a match in a string. It returns the index of the match, or -1
* if not found.
*
* @param string String to match.
* @return Index of match.
*/
int search(final String string) {
final RegExpResult match = execInner(string);
if (match == null) {
return -1;
}
return match.getIndex();
}
示例3: NativeRegExpExecResult
import jdk.nashorn.internal.runtime.regexp.RegExpResult; //导入方法依赖的package包/类
NativeRegExpExecResult(final RegExpResult result, final Global global) {
super(global.getArrayPrototype(), global.getRegExpExecResultMap());
setIsArray();
this.setArray(ArrayData.allocate(result.getGroups().clone()));
this.index = result.getIndex();
this.input = result.getInput();
}
示例4: search
import jdk.nashorn.internal.runtime.regexp.RegExpResult; //导入方法依赖的package包/类
/**
* Tests for a match in a string. It returns the index of the match, or -1
* if not found.
*
* @param string String to match.
* @return Index of match.
*/
Object search(final String string) {
final RegExpResult match = execInner(string);
if (match == null) {
return -1;
}
return match.getIndex();
}
示例5: split
import jdk.nashorn.internal.runtime.regexp.RegExpResult; //导入方法依赖的package包/类
/**
* Breaks up a string into an array of substrings based on a regular
* expression or fixed string.
*
* @param string String to match.
* @param limit Split limit.
* @return Array of substrings.
*/
NativeArray split(final String string, final long limit) {
if (limit == 0L) {
return new NativeArray();
}
final List<Object> matches = new ArrayList<>();
RegExpResult match;
final int inputLength = string.length();
int splitLastLength = -1;
int splitLastIndex = 0;
int splitLastLastIndex = 0;
while ((match = execSplit(string, splitLastIndex)) != null) {
splitLastIndex = match.getIndex() + match.length();
if (splitLastIndex > splitLastLastIndex) {
matches.add(string.substring(splitLastLastIndex, match.getIndex()));
final Object[] groups = match.getGroups();
if (groups.length > 1 && match.getIndex() < inputLength) {
for (int index = 1; index < groups.length && matches.size() < limit; index++) {
matches.add(groups[index]);
}
}
splitLastLength = match.length();
if (matches.size() >= limit) {
break;
}
}
// bump the index to avoid infinite loop
if (splitLastIndex == splitLastLastIndex) {
splitLastIndex++;
} else {
splitLastLastIndex = splitLastIndex;
}
}
if (matches.size() < limit) {
// check special case if we need to append an empty string at the
// end of the match
// if the lastIndex was the entire string
if (splitLastLastIndex == string.length()) {
if (splitLastLength > 0 || execSplit("", 0) == null) {
matches.add("");
}
} else {
matches.add(string.substring(splitLastLastIndex, inputLength));
}
}
return new NativeArray(matches.toArray());
}
示例6: split
import jdk.nashorn.internal.runtime.regexp.RegExpResult; //导入方法依赖的package包/类
/**
* Breaks up a string into an array of substrings based on a regular
* expression or fixed string.
*
* @param string String to match.
* @param limit Split limit.
* @return Array of substrings.
*/
Object split(final String string, final long limit) {
if (limit == 0L) {
return new NativeArray();
}
final List<Object> matches = new ArrayList<>();
RegExpResult match;
final int inputLength = string.length();
int splitLastLength = -1;
int splitLastIndex = 0;
int splitLastLastIndex = 0;
while ((match = execSplit(string, splitLastIndex)) != null) {
splitLastIndex = match.getIndex() + match.length();
if (splitLastIndex > splitLastLastIndex) {
matches.add(string.substring(splitLastLastIndex, match.getIndex()));
final Object[] groups = match.getGroups();
if (groups.length > 1 && match.getIndex() < inputLength) {
for (int index = 1; index < groups.length && matches.size() < limit; index++) {
matches.add(groups[index]);
}
}
splitLastLength = match.length();
if (matches.size() >= limit) {
break;
}
}
// bump the index to avoid infinite loop
if (splitLastIndex == splitLastLastIndex) {
splitLastIndex++;
} else {
splitLastLastIndex = splitLastIndex;
}
}
if (matches.size() < limit) {
// check special case if we need to append an empty string at the
// end of the match
// if the lastIndex was the entire string
if (splitLastLastIndex == string.length()) {
if (splitLastLength > 0 || execSplit("", 0) == null) {
matches.add("");
}
} else {
matches.add(string.substring(splitLastLastIndex, inputLength));
}
}
return new NativeArray(matches.toArray());
}