SplitWithRegExp() private static method

private static SplitWithRegExp ( String thisob, VsaEngine engine, RegExpObject regExpObject, uint limit ) : ArrayObject
thisob String
engine Microsoft.JScript.Vsa.VsaEngine
regExpObject RegExpObject
limit uint
return ArrayObject
示例#1
0
        public static ArrayObject split(Object thisob, VsaEngine engine, Object separator, Object limit)
        {
            String thisStr    = Convert.ToString(thisob);
            uint   limitValue = UInt32.MaxValue;

            if (limit != null && !(limit is Missing) && limit != DBNull.Value)
            {
                double lmt = Convert.ToInteger(limit);
                if (lmt >= 0 && lmt < UInt32.MaxValue)
                {
                    limitValue = (uint)lmt;
                }
            }
            if (limitValue == 0)
            {
                return((ArrayObject)engine.GetOriginalArrayConstructor().Construct());
            }
            if (separator == null || separator is Missing)
            {
                ArrayObject array = (ArrayObject)engine.GetOriginalArrayConstructor().Construct();
                array.SetValueAtIndex(0, thisob);
                return(array);
            }
            RegExpObject regExpObject = separator as RegExpObject;

            if (regExpObject != null)
            {
                return(StringPrototype.SplitWithRegExp(thisStr, engine, regExpObject, limitValue));
            }
            Regex regex = separator as Regex;

            if (regex != null)
            {
                return(StringPrototype.SplitWithRegExp(thisStr, engine, new RegExpObject(regex), limitValue));
            }
            return(StringPrototype.SplitWithString(thisStr, engine, Convert.ToString(separator), limitValue));
        }