ToRegExpObject() private static method

private static ToRegExpObject ( Object regExp, VsaEngine engine ) : RegExpObject
regExp Object
engine Microsoft.JScript.Vsa.VsaEngine
return RegExpObject
Example #1
0
        public static int search(Object thisob, VsaEngine engine, Object regExp)
        {
            String       thisStr      = Convert.ToString(thisob);
            RegExpObject regExpObject = StringPrototype.ToRegExpObject(regExp, engine);
            Match        match        = regExpObject.regex.Match(thisStr);

            if (!match.Success)
            {
                regExpObject.lastIndexInt = 0;
                return(-1);
            }
            regExpObject.lastIndexInt = regExpObject.regExpConst.UpdateConstructor(regExpObject.regex, match, thisStr);
            return(match.Index);
        }
Example #2
0
        public static Object match(Object thisob, VsaEngine engine, Object regExp)
        {
            String       thisStr      = Convert.ToString(thisob);
            RegExpObject regExpObject = StringPrototype.ToRegExpObject(regExp, engine);
            Match        match;

            if (!regExpObject.globalInt)
            {
                match = regExpObject.regex.Match(thisStr);
                if (!match.Success)
                {
                    regExpObject.lastIndexInt = 0;
                    return(DBNull.Value);
                }
                if (regExpObject.regExpConst != null)
                {
                    regExpObject.lastIndexInt = regExpObject.regExpConst.UpdateConstructor(regExpObject.regex, match, thisStr);
                    return(new RegExpMatch(regExpObject.regExpConst.arrayPrototype, regExpObject.regex, match, thisStr));
                }
                else
                {
                    return(new RegExpMatch(engine.Globals.globalObject.originalRegExp.arrayPrototype, regExpObject.regex, match, thisStr));
                }
            }
            MatchCollection matches = regExpObject.regex.Matches(thisStr);

            if (matches.Count == 0)
            {
                regExpObject.lastIndexInt = 0;
                return(DBNull.Value);
            }
            match = matches[matches.Count - 1];
            regExpObject.lastIndexInt = regExpObject.regExpConst.UpdateConstructor(regExpObject.regex, match, thisStr);
            return(new RegExpMatch(
                       regExpObject.regExpConst.arrayPrototype, regExpObject.regex, matches, thisStr));
        }