jdk.nashorn.internal.runtime.regexp.RegExpMatcher的实例源码

项目:openjdk-jdk10    文件JdkRegExpTest.java   
/**
 * Compile a regular expression using the JDK implementation
 */
@Test
public void testMatcher() {
    final RegExp regexp = new RegExpFactory().compile("f(o)o","");
    final RegExpMatcher matcher = regexp.match("foo");
    assertNotNull(matcher);
    assertTrue(matcher.search(0));
    assertEquals(matcher.getinput(),"foo");
    assertEquals(matcher.groupCount(),1);
    assertEquals(matcher.group(),"foo");
    assertEquals(matcher.start(),0);
    assertEquals(matcher.end(),3);
    assertEquals(matcher.group(1),"o");
    assertEquals(matcher.start(1),1);
    assertEquals(matcher.end(1),2);
}
项目:openjdk9    文件JdkRegExpTest.java   
/**
 * Compile a regular expression using the JDK implementation
 */
@Test
public void testMatcher() {
    final RegExp regexp = new RegExpFactory().compile("f(o)o",2);
}
项目:kaziranga    文件JdkRegExpTest.java   
/**
 * Compile a regular expression using the JDK implementation
 */
@Test
public void testMatcher() {
    final RegExp regexp = new RegExpFactory().compile("f(o)o",2);
}
项目:lookaside_java-1.8.0-openjdk    文件JdkRegExpTest.java   
/**
 * Compile a regular expression using the JDK implementation
 */
@Test
public void testMatcher() {
    final RegExp regexp = new RegExpFactory().compile("f(o)o",2);
}
项目:jdk8u_nashorn    文件JdkRegExpTest.java   
/**
 * Compile a regular expression using the JDK implementation
 */
@Test
public void testMatcher() {
    final RegExp regexp = new RegExpFactory().compile("f(o)o",2);
}
项目:Openjsharp    文件NativeRegExp.java   
private String callReplaceValue(final MethodHandle invoker,final ScriptFunction function,final Object self,final RegExpMatcher matcher,final String string) throws Throwable {
    final Object[] groups = groups(matcher);
    final Object[] args   = Arrays.copyOf(groups,groups.length + 2);

    args[groups.length]     = matcher.start();
    args[groups.length + 1] = string;

    return (String)invoker.invokeExact(function,self,args);
}
项目:openjdk-jdk10    文件NativeRegExp.java   
private String callReplaceValue(final MethodHandle invoker,final Object function,args);
}
项目:openjdk9    文件NativeRegExp.java   
private String callReplaceValue(final MethodHandle invoker,args);
}
项目:kaziranga    文件NativeRegExp.java   
private String callReplaceValue(final MethodHandle invoker,args);
}
项目:lookaside_java-1.8.0-openjdk    文件NativeRegExp.java   
private String callReplaceValue(final MethodHandle invoker,args);
}
项目:jdk8u_nashorn    文件NativeRegExp.java   
private String callReplaceValue(final MethodHandle invoker,args);
}
项目:infobip-open-jdk-8    文件NativeRegExp.java   
private String callReplaceValue(final MethodHandle invoker,args);
}
项目:OLD-OpenJDK8    文件NativeRegExp.java   
private String callReplaceValue(final ScriptFunction function,final String string) {
    final Object[] groups = groups(matcher);
    final Object[] args   = Arrays.copyOf(groups,groups.length + 2);

    args[groups.length]     = matcher.start();
    args[groups.length + 1] = string;

    final Object self = function.isstrict() ? UNDEFINED : Global.instance();

    return JSType.toString(ScriptRuntime.apply(function,args));
}
项目:nashorn-backport    文件NativeRegExp.java   
private String callReplaceValue(final ScriptFunction function,args));
}
项目:nashorn    文件NativeRegExp.java   
private String callReplaceValue(final ScriptFunction function,args));
}
项目:Openjsharp    文件NativeRegExp.java   
private void appendReplacement(final RegExpMatcher matcher,final String text,final String replacement,final StringBuilder sb) {
    /*
     * Process substitution patterns:
     *
     * $$ -> $
     * $& -> the matched substring
     * $` -> the portion of string that preceeds matched substring
     * $' -> the portion of string that follows the matched substring
     * $n -> the nth capture,where n is [1-9] and $n is NOT followed by a decimal digit
     * $nn -> the nnth capture,where nn is a two digit decimal number [01-99].
     */

    int cursor = 0;
    Object[] groups = null;

    while (cursor < replacement.length()) {
        char nextChar = replacement.charat(cursor);
        if (nextChar == '$') {
            // Skip past $
            cursor++;
            if (cursor == replacement.length()) {
                // nothing after "$"
                sb.append('$');
                break;
            }

            nextChar = replacement.charat(cursor);
            final int firstDigit = nextChar - '0';

            if (firstDigit >= 0 && firstDigit <= 9 && firstDigit <= matcher.groupCount()) {
                // $0 is not supported,but $01 is. implementation-defined: if n>m,ignore second digit.
                int refNum = firstDigit;
                cursor++;
                if (cursor < replacement.length() && firstDigit < matcher.groupCount()) {
                    final int secondDigit = replacement.charat(cursor) - '0';
                    if (secondDigit >= 0 && secondDigit <= 9) {
                        final int newRefNum = firstDigit * 10 + secondDigit;
                        if (newRefNum <= matcher.groupCount() && newRefNum > 0) {
                            // $nn ($01-$99)
                            refNum = newRefNum;
                            cursor++;
                        }
                    }
                }
                if (refNum > 0) {
                    if (groups == null) {
                        groups = groups(matcher);
                    }
                    // Append group if matched.
                    if (groups[refNum] != UNDEFINED) {
                        sb.append((String) groups[refNum]);
                    }
                } else { // $0. ignore.
                    assert refNum == 0;
                    sb.append("$0");
                }
            } else if (nextChar == '$') {
                sb.append('$');
                cursor++;
            } else if (nextChar == '&') {
                sb.append(matcher.group());
                cursor++;
            } else if (nextChar == '`') {
                sb.append(text,matcher.start());
                cursor++;
            } else if (nextChar == '\'') {
                sb.append(text,matcher.end(),text.length());
                cursor++;
            } else {
                // unkNown substitution or $n with n>m. skip.
                sb.append('$');
            }
        } else {
            sb.append(nextChar);
            cursor++;
        }
    }
}
项目:openjdk-jdk10    文件NativeRegExp.java   
private void appendReplacement(final RegExpMatcher matcher,final StringBuilder sb) {
    /*
     * Process substitution patterns:
     *
     * $$ -> $
     * $& -> the matched substring
     * $` -> the portion of string that precedes matched substring
     * $' -> the portion of string that follows the matched substring
     * $n -> the nth capture,text.length());
                cursor++;
            } else {
                // unkNown substitution or $n with n>m. skip.
                sb.append('$');
            }
        } else {
            sb.append(nextChar);
            cursor++;
        }
    }
}
项目:openjdk9    文件NativeRegExp.java   
private void appendReplacement(final RegExpMatcher matcher,text.length());
                cursor++;
            } else {
                // unkNown substitution or $n with n>m. skip.
                sb.append('$');
            }
        } else {
            sb.append(nextChar);
            cursor++;
        }
    }
}
项目:kaziranga    文件NativeRegExp.java   
private void appendReplacement(final RegExpMatcher matcher,text.length());
                cursor++;
            } else {
                // unkNown substitution or $n with n>m. skip.
                sb.append('$');
            }
        } else {
            sb.append(nextChar);
            cursor++;
        }
    }
}
项目:lookaside_java-1.8.0-openjdk    文件NativeRegExp.java   
private void appendReplacement(final RegExpMatcher matcher,text.length());
                cursor++;
            } else {
                // unkNown substitution or $n with n>m. skip.
                sb.append('$');
            }
        } else {
            sb.append(nextChar);
            cursor++;
        }
    }
}
项目:jdk8u_nashorn    文件NativeRegExp.java   
private void appendReplacement(final RegExpMatcher matcher,text.length());
                cursor++;
            } else {
                // unkNown substitution or $n with n>m. skip.
                sb.append('$');
            }
        } else {
            sb.append(nextChar);
            cursor++;
        }
    }
}
项目:infobip-open-jdk-8    文件NativeRegExp.java   
private void appendReplacement(final RegExpMatcher matcher,text.length());
                cursor++;
            } else {
                // unkNown substitution or $n with n>m. skip.
                sb.append('$');
            }
        } else {
            sb.append(nextChar);
            cursor++;
        }
    }
}
项目:OLD-OpenJDK8    文件NativeRegExp.java   
private void appendReplacement(final RegExpMatcher matcher,where nn is a two digit decimal number [01-99].
     */

    int cursor = 0;
    Object[] groups = null;

    while (cursor < replacement.length()) {
        char nextChar = replacement.charat(cursor);
        if (nextChar == '$') {
            // Skip past $
            cursor++;
            nextChar = replacement.charat(cursor);
            final int firstDigit = nextChar - '0';

            if (firstDigit >= 0 && firstDigit <= 9 && firstDigit <= matcher.groupCount()) {
                // $0 is not supported,ignore second digit.
                int refNum = firstDigit;
                cursor++;
                if (cursor < replacement.length() && firstDigit < matcher.groupCount()) {
                    final int secondDigit = replacement.charat(cursor) - '0';
                    if ((secondDigit >= 0) && (secondDigit <= 9)) {
                        final int newRefNum = (firstDigit * 10) + secondDigit;
                        if (newRefNum <= matcher.groupCount() && newRefNum > 0) {
                            // $nn ($01-$99)
                            refNum = newRefNum;
                            cursor++;
                        }
                    }
                }
                if (refNum > 0) {
                    if (groups == null) {
                        groups = groups(matcher);
                    }
                    // Append group if matched.
                    if (groups[refNum] != UNDEFINED) {
                        sb.append((String) groups[refNum]);
                    }
                } else { // $0. ignore.
                    assert refNum == 0;
                    sb.append("$0");
                }
            } else if (nextChar == '$') {
                sb.append('$');
                cursor++;
            } else if (nextChar == '&') {
                sb.append(matcher.group());
                cursor++;
            } else if (nextChar == '`') {
                sb.append(text,text.length());
                cursor++;
            } else {
                // unkNown substitution or $n with n>m. skip.
                sb.append('$');
            }
        } else {
            sb.append(nextChar);
            cursor++;
        }
    }
}
项目:nashorn-backport    文件NativeRegExp.java   
private void appendReplacement(final RegExpMatcher matcher,text.length());
                cursor++;
            } else {
                // unkNown substitution or $n with n>m. skip.
                sb.append('$');
            }
        } else {
            sb.append(nextChar);
            cursor++;
        }
    }
}
项目:nashorn    文件NativeRegExp.java   
private void appendReplacement(final RegExpMatcher matcher,text.length());
                cursor++;
            } else {
                // unkNown substitution or $n with n>m. skip.
                sb.append('$');
            }
        } else {
            sb.append(nextChar);
            cursor++;
        }
    }
}

相关文章

买水果
比较全面的redis工具类
gson 反序列化到多态子类
java 版本的 mb_strwidth
JAVA 反转字符串的最快方法,大概比StringBuffer.reverse()性...
com.google.gson.internal.bind.ArrayTypeAdapter的实例源码...