Microsoft.JScript.RegExpObject.compile C# (CSharp) Method

compile() private method

private compile ( String source, String flags ) : RegExpObject
source String
flags String
return RegExpObject
      internal RegExpObject compile(String source, String flags){
        this.sourceInt = source;
        this.ignoreCaseInt = this.globalInt = this.multilineInt = false;
        RegexOptions regexFlags = RegexOptions.CultureInvariant | RegexOptions.ECMAScript;
        for (int i = 0; i < flags.Length; i++)
          switch (flags[i]){
            case 'i':
              if (this.ignoreCaseInt)
                throw new JScriptException(JSError.RegExpSyntax);
              this.ignoreCaseInt = true;
              regexFlags |= RegexOptions.IgnoreCase;
              break;
            case 'g':
              if (this.globalInt)
                throw new JScriptException(JSError.RegExpSyntax);
              this.globalInt = true;
              break;
            case 'm':
              if (this.multilineInt)
                throw new JScriptException(JSError.RegExpSyntax);
              this.multilineInt = true;
              regexFlags |= RegexOptions.Multiline;
              break;
            default:
              throw new JScriptException(JSError.RegExpSyntax);
          }
        try{
          this.regex = new Regex(source, regexFlags);
        }catch (System.ArgumentException){
          throw new JScriptException(JSError.RegExpSyntax);
        }
        return this;
      }

Usage Example

コード例 #1
0
        public static RegExpObject compile(object thisob, object source, object flags)
        {
            RegExpObject obj2 = thisob as RegExpObject;

            if (obj2 == null)
            {
                throw new JScriptException(JSError.RegExpExpected);
            }
            return(obj2.compile(((source == null) || (source is Missing)) ? "" : Microsoft.JScript.Convert.ToString(source), ((flags == null) || (flags is Missing)) ? "" : Microsoft.JScript.Convert.ToString(flags)));
        }
All Usage Examples Of Microsoft.JScript.RegExpObject::compile