/// <summary>
        /// Creates a new regular expression instance by copying the pattern and flags from another
        /// RegExp instance.
        /// </summary>
        /// <param name="prototype"> The next object in the prototype chain. </param>
        /// <param name="existingInstance"> The instance to copy the pattern and flags from. </param>
        internal RegExpInstance(ObjectInstance prototype, RegExpInstance existingInstance)
            : base(prototype)
        {
            if (existingInstance == null)
            {
                throw new ArgumentNullException("existingInstance");
            }
            this.m_value        = existingInstance.m_value;
            this.m_globalSearch = existingInstance.m_globalSearch;

            // Initialize the javascript properties.
            this.FastSetProperty("source", existingInstance.Source, PropertyAttributes.Sealed, false);
            this.FastSetProperty("global", existingInstance.Global, PropertyAttributes.Sealed, false);
            this.FastSetProperty("multiline", existingInstance.Multiline, PropertyAttributes.Sealed, false);
            this.FastSetProperty("ignoreCase", existingInstance.IgnoreCase, PropertyAttributes.Sealed, false);
            this.FastSetProperty("lastIndex", 0.0, PropertyAttributes.Writable, false);
        }
Esempio n. 2
0
 /// <summary>
 /// Returns a copy of this string with text replaced using a regular expression and a
 /// replacement function.
 /// </summary>
 /// <param name="thisObject"></param>
 /// <param name="regExp"> The regular expression to search for. </param>
 /// <param name="replaceFunction"> A function that is called to produce the text to replace
 /// for every successful match. </param>
 /// <returns> A copy of this string with text replaced using a regular expression. </returns>
 public static string Replace(string thisObject, RegExpInstance regExp, FunctionInstance replaceFunction)
 {
     return(regExp.Replace(thisObject, replaceFunction));
 }
Esempio n. 3
0
        /// <summary>
        /// Splits this string into an array of strings by separating the string into substrings.
        /// </summary>
        /// <param name="thisObject"></param>
        /// <param name="regExp"> A regular expression that indicates where to split the string. </param>
        /// <param name="limitArg"> The maximum number of array items to return.  Defaults to unlimited. </param>
        /// <returns> An array containing the split strings. </returns>
        public static ArrayInstance Split(string thisObject, RegExpInstance regExp, [DefaultParameterValue(uint.MaxValue)] object limitArg)
        {
            var limit = JurassicHelper.GetTypedArgumentValue(regExp.Engine, limitArg, uint.MaxValue);

            return(regExp.Split(thisObject, limit));
        }
Esempio n. 4
0
 /// <summary>
 /// Returns a copy of this string with text replaced using a regular expression.
 /// </summary>
 /// <param name="thisObject"></param>
 /// <param name="regExp"> The regular expression to search for. </param>
 /// <param name="replaceText"> A string containing the text to replace for every successful match. </param>
 /// <returns> A copy of this string with text replaced using a regular expression. </returns>
 public static string Replace(string thisObject, RegExpInstance regExp, string replaceText)
 {
     return(regExp.Replace(thisObject, replaceText));
 }