예제 #1
0
 protected override void AppendCharacterRangeToBracketExpression(
     char startOfCharacterRange,
     char endOfCharacterRange)
 {
     WildcardPatternToRegexParser.AppendCharacterRangeToBracketExpression(
         _bracketExpressionBuilder,
         startOfCharacterRange,
         endOfCharacterRange);
 }
예제 #2
0
 public static WildcardPatternMatcher.PatternElement[] Parse(WildcardPattern pattern, WildcardPatternMatcher.CharacterNormalizer characterNormalizer)
 {
     WildcardPatternMatcher.MyWildcardPatternParser parser = new WildcardPatternMatcher.MyWildcardPatternParser {
         _characterNormalizer = characterNormalizer,
         _regexOptions        = WildcardPatternToRegexParser.TranslateWildcardOptionsIntoRegexOptions(pattern.Options)
     };
     WildcardPatternParser.Parse(pattern, parser);
     return(parser._patternElements.ToArray());
 }
예제 #3
0
        /// <summary>
        /// Parses a <paramref name="wildcardPattern"/> into a <see cref="Regex"/>
        /// </summary>
        /// <param name="wildcardPattern">Wildcard pattern to parse.</param>
        /// <returns>Regular expression equivalent to <paramref name="wildcardPattern"/></returns>
        public static Regex Parse(WildcardPattern wildcardPattern)
        {
            WildcardPatternToRegexParser parser = new WildcardPatternToRegexParser();

            WildcardPatternParser.Parse(wildcardPattern, parser);
            try
            {
                return(new Regex(parser._regexPattern.ToString(), parser._regexOptions));
            }
            catch (ArgumentException)
            {
                throw WildcardPatternParser.NewWildcardPatternException(wildcardPattern.Pattern);
            }
        }
예제 #4
0
 private bool Init()
 {
     if (this._isMatch == null)
     {
         if (false)
         {
             Regex regex = WildcardPatternToRegexParser.Parse(this);
             this._isMatch = new Predicate <string>(regex.IsMatch);
         }
         else
         {
             WildcardPatternMatcher matcher = new WildcardPatternMatcher(this);
             this._isMatch = new Predicate <string>(matcher.IsMatch);
         }
     }
     return(this._isMatch != null);
 }
예제 #5
0
 protected override void AppendLiteralCharacterToBracketExpression(char c)
 {
     WildcardPatternToRegexParser.AppendLiteralCharacterToBracketExpression(
         _bracketExpressionBuilder,
         c);
 }
예제 #6
0
파일: regex.cs 프로젝트: 40a/PowerShell
 /// <summary>
 /// Parses a <paramref name="wildcardPattern"/> into a <see cref="Regex"/>
 /// </summary>
 /// <param name="wildcardPattern">Wildcard pattern to parse</param>
 /// <returns>Regular expression equivalent to <paramref name="wildcardPattern"/></returns>
 public static Regex Parse(WildcardPattern wildcardPattern)
 {
     WildcardPatternToRegexParser parser = new WildcardPatternToRegexParser();
     WildcardPatternParser.Parse(wildcardPattern, parser);
     try
     {
         return new Regex(parser._regexPattern.ToString(), parser._regexOptions);
     }
     catch (ArgumentException)
     {
         throw WildcardPatternParser.NewWildcardPatternException(wildcardPattern.Pattern);
     }
 }