Example #1
0
        /// <summary>
        ///
        /// </summary>
        public Number search(RegExp regex)
        {
            this.CheckUndefined();

            string text  = GetText(this);
            Match  match = regex.Match(text);

            if (match.Success)
            {
                return(match.Index);
            }
            return(-1);
        }
Example #2
0
        public Array <String> split(RegExp regex)
        {
            this.CheckUndefined();

            Array <String> ret = new Array <String>();

            string text = GetText(this);

            string[] parts = regex.Split(text);
            foreach (string part in parts)
            {
                ret.Add(part);
            }
            return(ret);
        }
Example #3
0
        /// <summary>
        ///
        /// </summary>
        public String replace(RegExp regex, String replacement)
        {
            this.CheckUndefined();

            string text = GetText(this);

            if (regex.global)
            {
                return(regex.Replace(text, replacement));
            }
            else
            {
                return(regex.Replace(text, replacement, 1));
            }
        }
Example #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pattern"></param>
        /// <returns></returns>
        public RegExpArray match(string pattern)
        {
            this.CheckUndefined();

            string input = GetText(this);

            if (!RegExp.IsMatch(input, pattern))
            {
                return(null);
            }

            RegExpArray ret   = new RegExpArray();
            Match       match = RegExp.Match(input, pattern);

            foreach (Group g in match.Groups)
            {
                ret.push(g.Value);
            }
            ret.input = input;
            ret.index = match.Index;

            return(ret);
        }