Java Javascript Mozilla Library toRegExp(String source, String optionsString)

Here you can find the source of toRegExp(String source, String optionsString)

Description

to Reg Exp

License

Mozilla Public License

Declaration

public static Scriptable toRegExp(String source, String optionsString) 

Method Source Code

//package com.java2s;
/**// w  ww  .  ja  v a  2s.  co  m
 * Copyright 2010-2016 Three Crickets LLC.
 * <p>
 * The contents of this file are subject to the terms of the Mozilla Public
 * License version 1.1: http://www.mozilla.org/MPL/MPL-1.1.html
 * <p>
 * Alternatively, you can obtain a royalty free commercial license with less
 * limitations, transferable or non-transferable, directly from Three Crickets
 * at http://threecrickets.com/
 */

import org.mozilla.javascript.Context;

import org.mozilla.javascript.ScriptRuntime;
import org.mozilla.javascript.Scriptable;

public class Main {
    public static Scriptable toRegExp(String source, String optionsString) {
        Context context = Context.getCurrentContext();
        Scriptable scope = ScriptRuntime.getTopCallScope(context);
        return context.newObject(scope, "RegExp", new Object[] { source, optionsString });
    }

    public static Scriptable newObject() {
        Context context = Context.getCurrentContext();
        Scriptable scope = ScriptRuntime.getTopCallScope(context);
        return context.newObject(scope);
    }
}

Related

  1. stringValue(String name, Scriptable scope)
  2. toInt(Object obj, int defaultValue)
  3. toJavaBoolean(final Scriptable options, final String key)
  4. toJavaInt(final Object fromScript)
  5. toList(AstNode... nodes)
  6. toString(Object val)
  7. trace(Object object)
  8. traceHelper(Function function, Object... args)
  9. unwrap(Object obj)