protected override NodeResultBuilder GetValue() { string suffix = GetSuffix( InputCount.Value, InputNumber.InputContents, InputMin.GetValue(), InputMax.GetValue()); var builder = new NodeResultBuilder(ValueString(), this); builder.Append(suffix, this); return(builder); }
protected override string GetValue() { string result; string suffix = Quantifier.Repetitions.GetSuffix( InputCount.DropdownValue, InputNumber.InputContents, InputMin.GetValue(), InputMax.GetValue()); if (InputAllowAll.IsChecked) { result = "."; return(UpdateCache(result + suffix)); } var inputs = ( w : InputAllowWhitespace.IsChecked, L : InputAllowUppercase.IsChecked, l : InputAllowLowercase.IsChecked, d : InputAllowDigits.IsChecked, u : InputAllowUnderscore.IsChecked, o : InputAllowOther.IsChecked ); result = inputs switch { //Handle special cases where simplification is possible - when "other' is ticked (true, true, true, true, true, true) => @".", (true, true, true, false, true, true) => @"\D", (false, true, true, true, true, true) => @"\S", (true, false, false, false, false, true) => @"\W", //Handle special cases where simplification is possible - when "other' is not ticked (false, false, false, false, false, false) => "", (false, false, false, false, true, false) => @"_", (false, false, false, true, false, false) => @"\d", (true, false, false, false, false, false) => @"\s", (false, true, true, true, true, false) => @"\w", //Handle general case when "other' is ticked _ when inputs.o => "[^" + GetClassContents(w: !inputs.w, L: !inputs.L, l: !inputs.l, d: !inputs.d, u: !inputs.u) + "]", //Handle general case when "other' is not ticked _ => "[" + GetClassContents(w: inputs.w, L: inputs.L, l: inputs.l, d: inputs.d, u: inputs.u) + "]", };
protected override NodeResultBuilder GetValue() { string charSet = InputCharacters.GetValue(); string prefix = InputDoInvert.IsChecked ? "^" : ""; string result = "[" + prefix + charSet + "]"; string suffix = GetSuffix( InputCount.Value, InputNumber.InputContents, InputMin.GetValue(), InputMax.GetValue()); var builder = new NodeResultBuilder(); builder.Append(result, this); builder.Append(suffix, this); return(builder); }
protected override string GetValue() { string charSet = InputCharacters.GetValue(); if (String.IsNullOrEmpty(charSet)) { return(UpdateCache("")); } string prefix = InputDoInvert.IsChecked ? "^" : ""; string result = "[" + prefix + charSet + "]"; string suffix = Quantifier.Repetitions.GetSuffix( InputCount.DropdownValue, InputNumber.InputContents, InputMin.GetValue(), InputMax.GetValue()); return(UpdateCache(result + suffix)); }
protected override NodeResultBuilder GetValue() { var builder = new NodeResultBuilder(InputContents.Value); string suffix = ""; string prefix = ""; //Surround with non-capturing group if necessary if (InputContents.ConnectedNode is Node _node && RequiresGroupToQuantify(_node)) { prefix += "(?:"; suffix += ")"; } //Add quantifier suffix += GetSuffix( InputCount.Value, InputNumber.InputContents, InputMin.GetValue(), InputMax.GetValue()); //Add modifier if (InputCount.Value != Reps.Number) { if (InputSearchType.Value == SearchMode.Lazy) { suffix += "?"; } else if (InputSearchType.Value == SearchMode.Possessive) { suffix += ")"; prefix = "(?>" + prefix; } } builder.Prepend(prefix, this); builder.Append(suffix, this); return(builder); }
public override string GetValue() { string suffix = ""; //int min = InputMin.GetValue() ?? 0; //int? max = InputMax.GetValue(); switch (InputCount.DropdownValue) { case "Zero or more": suffix = "*"; break; case "One or more": suffix = "+"; break; case "Zero or one": suffix = "?"; break; case "Number": suffix = $"{{{InputNumber.InputContents}}}"; break; case "Range": int min = InputMin.GetValue() ?? 0; int?max = InputMax.GetValue(); suffix = $"{{{min},{max}}}"; break; } if (InputSearchType.DropdownValue == "Lazy") { suffix += "?"; } string contents = InputNode.GetValue(); if (!contents.IsSingleRegexChar()) { contents = contents.EnforceGrouped(); } string result = contents + suffix; return(UpdateCache(result)); }
protected override NodeResultBuilder GetValue() { bool invert = InputInvert.IsChecked; string suffix = GetSuffix( InputCount.Value, InputNumber.InputContents, InputMin.GetValue(), InputMax.GetValue()); string contents = (InputType.Value, invert) switch { (WildcardType.Everything, _) => InputMatchNewline.IsChecked ? @"[\s\S]" : ".", (WildcardType.WordCharacters, false) => "\\w", (WildcardType.WordCharacters, true) => "\\W", (WildcardType.Letters, false) => "[a-zA-Z]", (WildcardType.Letters, true) => "[^a-zA-Z]", (WildcardType.Digits, false) => "\\d", (WildcardType.Digits, true) => "\\D", (WildcardType.Whitespace, false) => "\\s", (WildcardType.Whitespace, true) => "\\S", (WildcardType.Custom, _) => GetContentsCustom(invert), _ => ".", };