/// <summary>
        ///
        /// </summary>
        public String replace(RegExp regex, Func <String, String, String, String, String> func)
        {
            this.CheckUndefined();

            string text = GetText(this);

            if (!regex.IsMatch(text))
            {
                return(this);
            }

            if (regex.global)
            {
                string result = "";
                int    index  = 0;
                foreach (Match match in regex.Matches(text))
                {
                    GroupCollection groups      = match.Groups;
                    string          replacement = func(groups[0].Value, groups[1].Value, groups[2].Value, groups[3].Value);
                    result += (text.Substring(index, match.Index - index) + match.Result(replacement));
                    index   = match.Index + match.Length;
                }
                result += text.Substring(index);
                return(result);
            }
            else
            {
                Match           match       = regex.Match(text);
                GroupCollection groups      = match.Groups;
                string          replacement = func(groups[0].Value, groups[1].Value, groups[2].Value, groups[3].Value);
                return(text.Substring(0, match.Index) + match.Result(replacement) + text.Substring(match.Index + match.Length));
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="regex"></param>
        /// <returns></returns>
        public RegExpArray match(RegExp regex)
        {
            this.CheckUndefined();

            string input = GetText(this);

            if (!regex.IsMatch(input))
            {
                return(null);
            }

            RegExpArray ret = new RegExpArray();

            if (regex.global)
            {
                foreach (Match match in regex.Matches(input))
                {
                    ret.Add(match.Value);
                }
            }
            else
            {
                Match match = regex.Match(input);
                foreach (Group g in match.Groups)
                {
                    ret.Add(g.Value);
                }
                ret.input = input;
                ret.index = match.Index;
            }

            return(ret);
        }