Match() публичный Метод

Finds all regular expression matches within the given string.
public Match ( string input ) : object
input string The string on which to perform the search.
Результат object
Пример #1
0
        public static object Match(ScriptEngine engine, object thisObject, object substrOrRegExp)
        {
            if (thisObject == Null.Value || thisObject == Undefined.Value)
            {
                throw new JavaScriptException(ErrorType.TypeError, "String.prototype.match called on null or undefined.");
            }

            if (substrOrRegExp != Null.Value && substrOrRegExp != Undefined.Value)
            {
                // Get the [Symbol.match] property value.
                var matchFunctionObj = TypeConverter.ToObject(engine, substrOrRegExp)[Symbol.Match];
                if (matchFunctionObj != Undefined.Value)
                {
                    // If it's a function, call it and return the result.
                    if (matchFunctionObj is FunctionInstance matchFunction)
                    {
                        return(matchFunction.CallLateBound(substrOrRegExp, thisObject));
                    }
                    else
                    {
                        throw new JavaScriptException(ErrorType.TypeError, "Symbol.match value is not a function.");
                    }
                }
            }

            // Convert the argument to a regex.
            var regex = new RegExpInstance(engine.RegExp.InstancePrototype, TypeConverter.ToString(substrOrRegExp, string.Empty));

            // Call the [Symbol.match] function.
            return(regex.Match(TypeConverter.ToString(thisObject)));
        }