public RegExCaptureTransformerOptionsWindow(RegExCaptureTransformerConfig config) { InitializeComponent(); txtRegex.Text = config.Pattern; txtOutputFormat.Text = config.OutputFormat; chkUseDefault.IsChecked = config.DefaultIfNotMatch; txtDefault.Text = config.DefaultValue; }
private bool UpdateConfig(String pattern, String outputFormat, bool defaultIfNotMatch = false, String defaultValue = "") { // Counts the number of placeholders in the output format Regex = new Regex(pattern); PlaceholderCount = Regex.Matches(outputFormat, @"(?<!\{)\{([0-9]+).*?\}(?!})").Cast <Match>().Max(m => int.Parse(m.Groups[1].Value)) + 1; Options = new RegExCaptureTransformerConfig { Pattern = pattern, OutputFormat = outputFormat, DefaultIfNotMatch = defaultIfNotMatch, DefaultValue = defaultValue }; return(true); }
private bool UpdateConfig(String pattern, String outputFormat, bool defaultIfNotMatch = false, String defaultValue = "") { // Counts the number of placeholders in the output format Regex = new Regex(pattern); PlaceholderCount = Regex.Matches(outputFormat, @"(?<!\{)\{([0-9]+).*?\}(?!})").Cast<Match>().Max(m => int.Parse(m.Groups[1].Value)) + 1; Options = new RegExCaptureTransformerConfig { Pattern = pattern, OutputFormat = outputFormat, DefaultIfNotMatch = defaultIfNotMatch, DefaultValue = defaultValue }; return true; }