コード例 #1
0
        public override IRegexFindResults GetRegexFindResults(Match match)
        {
            VBRegexFindResults results = new VBRegexFindResults();

            results.FoundMatch = match.Success;
            if (results.FoundMatch)
            {
                results.ToMatch = GetStringFromGroup(match.Groups["tomatchstring"], results);
                if (match.Groups["tomatchnotstring"].Success)
                {
                    results.ToMatchExpression = match.Groups["tomatchnotstring"].Value;
                }
                results.ReplacePattern = GetStringFromGroup(match.Groups["replace"], results);
                if (match.Groups["onlyregex"].Success)
                {
                    results.IsMatchOnlyRegex = true;
                    results.Regex            = GetStringFromGroup(match.Groups["onlyregex"], results);
                }
                else
                {
                    results.Regex = GetStringFromGroup(match.Groups["regex"], results);
                }
                results.RegexNamespace = match.Groups["regexnamespace"].Success ? match.Groups["regexnamespace"].Captures[0].Value : null;
                RegexOptions options = RegexOptions.None;
                foreach (Capture capture in match.Groups["option"].Captures)
                {
                    options |= (RegexOptions)Enum.Parse(typeof(RegexOptions), capture.Value, false);
                }
                results.RegexOptions = options;
            }
            results.IsEdit          = false;
            results.CodeDomProvider = new VBCodeProvider();

            return(results);
        }
コード例 #2
0
 private string GetStringFromGroup(Group matchGroup, VBRegexFindResults results)
 {
     if (matchGroup.Success)
     {
         StringBuilder result = new StringBuilder();
         foreach (Capture capture in matchGroup.Captures)
         {
             string value = capture.Value;
             result.Append(results.EditToDisplayString(value.Substring(1, value.Length - 2)));
         }
         return(result.ToString());
     }
     return(null);
 }