当前位置: 首页>>代码示例>>Java>>正文


Java RegExpResult.getIndex方法代码示例

本文整理汇总了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();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:8,代码来源:NativeRegExpExecResult.java

示例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();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:17,代码来源:NativeRegExp.java

示例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();
}
 
开发者ID:RedlineResearch,项目名称:OLD-OpenJDK8,代码行数:8,代码来源:NativeRegExpExecResult.java

示例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();
}
 
开发者ID:RedlineResearch,项目名称:OLD-OpenJDK8,代码行数:17,代码来源:NativeRegExp.java

示例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());
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:64,代码来源:NativeRegExp.java

示例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());
}
 
开发者ID:RedlineResearch,项目名称:OLD-OpenJDK8,代码行数:64,代码来源:NativeRegExp.java


注:本文中的jdk.nashorn.internal.runtime.regexp.RegExpResult.getIndex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。