本文整理汇总了Java中jdk.nashorn.internal.runtime.regexp.RegExpFactory类的典型用法代码示例。如果您正苦于以下问题:Java RegExpFactory类的具体用法?Java RegExpFactory怎么用?Java RegExpFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RegExpFactory类属于jdk.nashorn.internal.runtime.regexp包,在下文中一共展示了RegExpFactory类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testMatcher
import jdk.nashorn.internal.runtime.regexp.RegExpFactory; //导入依赖的package包/类
/**
* 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);
}
示例2: NativeRegExp
import jdk.nashorn.internal.runtime.regexp.RegExpFactory; //导入依赖的package包/类
NativeRegExp(final String input, final String flagString, final Global global) {
this(global);
try {
this.regexp = RegExpFactory.create(input, flagString);
} catch (final ParserException e) {
// translate it as SyntaxError object and throw it
e.throwAsEcmaException();
throw new AssertionError(); //guard against null warnings below
}
this.setLastIndex(0);
}
示例3: NativeRegExp
import jdk.nashorn.internal.runtime.regexp.RegExpFactory; //导入依赖的package包/类
NativeRegExp(final String input, final String flagString, final Global global, final ScriptObject proto) {
super(proto, $nasgenmap$);
try {
this.regexp = RegExpFactory.create(input, flagString);
} catch (final ParserException e) {
// translate it as SyntaxError object and throw it
e.throwAsEcmaException();
throw new AssertionError(); //guard against null warnings below
}
this.globalObject = global;
this.setLastIndex(0);
}