Exemplo n.º 1
0
        public static Constant replace(Constant _this, Constant[] arguments, Scope scope)
        {
            var str = (Javascript.String)_this;

            if (arguments[0] is Javascript.String)
            {
                var search   = (Javascript.String)arguments[0];
                var newValue = (Javascript.String)arguments[1];

                return(new Javascript.String(str.Value.Replace(search.Value, newValue.Value)));
            }
            else if (arguments[0] is Javascript.Object)
            {
                return(RegExp.replace(arguments[0], new Constant[] { str, arguments[1] }, scope));
            }

            throw new Exception("first argument of string.replace must be a string or a RegExp");
        }
Exemplo n.º 2
0
 public static Constant test(Constant _this, Constant[] arguments, Scope scope)
 {
     return(RegExp.test(arguments[0], new Constant[] { _this }, scope));
 }