Beispiel #1
0
        public override void Edit()
        {
            SuperRegex grepper = null;

            switch ((ParameterList[2].GetValueOrDefault()).ToLower())
            {
            case "sql":
                string pattern = Regex.Replace(ParameterList[0].Value, @"(?<esc>[\.\}\{\+\*\\\?\|\)\(\$\^\#])", "\\${esc}");
                pattern = Regex.Replace(pattern, "(?!\\\\)_", ".");
                pattern = Regex.Replace(pattern, "(?!\\\\)%", @".*");
                grepper = Parameter.ClipEscape(String.Concat("/", pattern, "/mi")).ToSuperRegex();

                break;

            case "text":
                grepper = Regex.Escape(ParameterList[0].GetEscapedValue()).ToSuperRegex();
                break;

            default:
                grepper = ClipEscape(ParameterList[0].Value).ToSuperRegex();
                break;
            }

            MatchCollection matches   = grepper.Matches(SourceData);
            List <string>   matchlist = new List <string>();

            foreach (Match match in matches)
            {
                matchlist.Add(match.Value);
            }

            if (matchlist.Count == 0)
            {
                RespondToExe("Pattern did not find a match in the string");
            }
            else
            {
                SourceData = String.Join(Parameter.ClipEscape(ParameterList[1].GetValueOrDefault()), matchlist.ToArray());
            }
        }
Beispiel #2
0
        public override void Edit()
        {
            SuperRegex repper = null;

            switch ((ParameterList[2].Value ?? ParameterList[2].DefaultValue).ToLower())
            {
            case "sql":
                string pattern = Regex.Replace(ParameterList[0].Value, @"(?<esc>[\.\}\{\+\*\\\?\|\)\(\$\^\#])", "\\${esc}");
                pattern = Regex.Replace(pattern, "(?!\\\\)_", ".");
                pattern = Regex.Replace(pattern, "(?!\\\\)%", @"(.|\n)*");
                repper  = ClipEscape(pattern).ToSuperRegex();
                break;

            case "text":
                repper = Regex.Escape(ClipEscape(ParameterList[0].Value)).ToSuperRegex();
                break;

            default:
                repper = ClipEscape(ParameterList[0].Value).ToSuperRegex();
                break;
            }

            SourceData = repper.SuperReplace(SourceData, ClipEscape(ParameterList[1].Value));
        }