예제 #1
0
        public static string SetRegexOptions(string options)
        {
            RegexOptions     newRegexOptions     = RegexOptions.None;
            RegexSyntaxModes newRegexSyntaxModes = RegexSyntaxModes.POSIXExtendedRegex;

            foreach (char c in options)
            {
                switch (c)
                {
                case 'i':
                    newRegexOptions |= RegexOptions.AmbiguityMatch;
                    break;

                case 'x':
                    newRegexOptions |= RegexOptions.ExtendedPatternForm;
                    break;

                case 'm':
                    newRegexOptions |= RegexOptions.DotMatchesNewLine;
                    break;

                case 's':
                    newRegexOptions |= RegexOptions.ConvertMatchBeginEnd;
                    break;

                case 'p':
                    newRegexOptions |= RegexOptions.DotMatchesNewLine | RegexOptions.ConvertMatchBeginEnd;
                    break;

                case 'l':
                    newRegexOptions |= RegexOptions.FindLongestMatch;
                    break;

                case 'n':
                    newRegexOptions |= RegexOptions.IgnoreEmptyMatch;
                    break;

                case 'e':
                    newRegexOptions |= RegexOptions.EvalResultingCode;
                    break;

                case 'd':
                    newRegexSyntaxModes = RegexSyntaxModes.POSIXExtendedRegex;
                    break;

                default:
                    PhpException.ArgumentValueNotSupported("options", c);
                    break;
                }
            }

            //
            _regexOptions    = newRegexOptions;
            _regexSyntaxMode = newRegexSyntaxModes;

            return(GetRegexOptions());
        }
예제 #2
0
 /// <summary>
 /// Determines if given syntax mode is set.
 /// </summary>
 /// <param name="opt">Syntax mode to test.</param>
 /// <returns>True if given syntax mode is enabled.</returns>
 private static bool OptionEnabled(RegexSyntaxModes opt)
 {
     return(_regexSyntaxMode == opt);
 }
예제 #3
0
파일: MbString.cs 프로젝트: proff/Phalanger
 /// <summary>
 /// Determines if given syntax mode is set.
 /// </summary>
 /// <param name="opt">Syntax mode to test.</param>
 /// <returns>True if given syntax mode is enabled.</returns>
 private static bool OptionEnabled(RegexSyntaxModes opt)
 {
     return (_regexSyntaxMode == opt);
 }
예제 #4
0
파일: MbString.cs 프로젝트: proff/Phalanger
        public static string SetRegexOptions(string options)
        {
            RegexOptions newRegexOptions = RegexOptions.None;
            RegexSyntaxModes newRegexSyntaxModes = RegexSyntaxModes.POSIXExtendedRegex;

            foreach (char c in options)
            {
                switch (c)
                {
                    case 'i':
                        newRegexOptions |= RegexOptions.AmbiguityMatch;
                        break;
                    case 'x':
                        newRegexOptions |= RegexOptions.ExtendedPatternForm;
                        break;
                    case 'm':
                        newRegexOptions |= RegexOptions.DotMatchesNewLine;
                        break;
                    case 's':
                        newRegexOptions |= RegexOptions.ConvertMatchBeginEnd;
                        break;
                    case 'p':
                        newRegexOptions |= RegexOptions.DotMatchesNewLine | RegexOptions.ConvertMatchBeginEnd;
                        break;
                    case 'l':
                        newRegexOptions |= RegexOptions.FindLongestMatch;
                        break;
                    case 'n':
                        newRegexOptions |= RegexOptions.IgnoreEmptyMatch;
                        break;
                    case 'e':
                        newRegexOptions |= RegexOptions.EvalResultingCode;
                        break;

                    case 'd':
                        newRegexSyntaxModes = RegexSyntaxModes.POSIXExtendedRegex;
                        break;

                    default:
                        PhpException.ArgumentValueNotSupported("options", c);
                        break;
                }
            }

            //
            _regexOptions = newRegexOptions;
            _regexSyntaxMode = newRegexSyntaxModes;

            return GetRegexOptions();
        }
예제 #5
0
 /// <summary>
 /// Determines if given syntax mode is set.
 /// </summary>
 /// <param name="opt">Syntax mode to test.</param>
 /// <returns>True if given syntax mode is enabled.</returns>
 private static bool OptionEnabled(RegexSyntaxModes opt)
 {
     return (StaticInfo.Get.RegexSyntaxMode == opt);
 }