protected override NodeResultBuilder GetValue() { var builder = new NodeResultBuilder(); //check whether nothing is connected to this node. if (PreviousNode is null) { builder.Append("Nothing connected to Output node", this); return(builder); } builder.Append(Previous.Value); //Prefix switch (InputStartsAt.Value) { case Mode.StartLine: builder.Prepend("^", this); break; case Mode.WordBound: builder.Prepend("\\b", this); break; } //Suffix switch (InputEndsAt.Value) { case Mode.EndLine: builder.Append("$", this); break; case Mode.WordBound: builder.Append("\\b", this); break; } if (PreviousNode is OrNode) { builder.StripNonCaptureGroup(); } return(builder); }
protected override NodeResultBuilder GetValue() { string flagsOn = ""; flagsOn += OptionIgnoreCase.CheckedState == 1 ? "i" : ""; flagsOn += OptionMultiline.CheckedState == 1 ? "m" : ""; flagsOn += OptionSingleline.CheckedState == 1 ? "s" : ""; flagsOn += OptionExplicitCapture.CheckedState == 1 ? "n" : ""; flagsOn += OptionIgnoreWhitespace.CheckedState == 1 ? "x" : ""; string flagsOff = ""; flagsOff += OptionIgnoreCase.CheckedState == -1 ? "i" : ""; flagsOff += OptionMultiline.CheckedState == -1 ? "m" : ""; flagsOff += OptionSingleline.CheckedState == -1 ? "s" : ""; flagsOff += OptionExplicitCapture.CheckedState == -1 ? "n" : ""; flagsOff += OptionIgnoreWhitespace.CheckedState == -1 ? "x" : ""; if (!String.IsNullOrEmpty(flagsOff)) { flagsOff = "-" + flagsOff; } var builder = new NodeResultBuilder(); builder.Append("(?" + flagsOn + flagsOff, this); if (InputContents.IsConnected) { builder.Append(":", this); builder.Append(InputContents.Value); } builder.Append(")", this); return(builder); }
protected override NodeResultBuilder GetValue() { string charSet = InputCharacters.GetValue(); string prefix = InputDoInvert.Checked ? "^" : ""; string result = "[" + prefix + charSet + "]"; string suffix = GetSuffix(this); var builder = new NodeResultBuilder(); builder.Append(result, this); builder.Append(suffix, this); return(builder); }
protected override NodeResultBuilder GetValue() { //return null; var builder = new NodeResultBuilder(); //string condition = ConditionType.DropdownValue == "Expression" ? InputCondition.GetValue() : InputGroupID.GetValue(); string condition = InputCondition.GetValue(); builder.Append($"(?({condition})", this); builder.Append(InputThen.Value); builder.Append("|", this); builder.Append(InputElse.Value); builder.Append(")", this); //return $"(?({condition}){InputThen.GetValue()}|{InputElse.GetValue()})"; return(builder); }
protected override NodeResultBuilder GetValue() { var builder = new NodeResultBuilder(Input.Value); if (Input.ConnectedNode is OrNode || Input.ConnectedNode is IntegerNode ) { builder.StripNonCaptureGroup(); } string prefix = InputGroupType.Value switch { GroupTypes.capturing => "(", GroupTypes.nonCapturing => "(?:", GroupTypes.named => $"(?<{GroupName.GetValue()}>", GroupTypes.atomic => $"(?>", GroupTypes.custom => "(" + CustomPrefix.GetValue(), _ => "", }; builder.Prepend(prefix, this); builder.Append(")", this); return(builder); }
protected override NodeResultBuilder GetValue() { var builder = new NodeResultBuilder(InputContents.Value); string whitespace = InputAllowWhitespace.Checked ? "\\s*?" : ""; string separator = InputSeparator.Value; if (!InputAllowRegex.Checked) { separator = separator.EscapeCharacters(SeparatorCharsToEscape); } int minReps = InputListLength.Min ?? 0; int? maxReps = InputListLength.Max; string quantifier = (min : minReps, max : maxReps) switch { (0, 2) => "?", (1, 2) => "?", (0, null) => "*", (1, null) => "*", (2, null) => "+", (0, int max) => $"{{{0},{max - 1}}}", var range when range.min == range.max => $"{{{range.min - 1}}}", var range => $"{{{range.min - 1},{range.max - 1}}}" }; if (InputLazyQuantifier.Checked) { quantifier += "?"; } string suffix = ")" + quantifier; if (minReps <= 0) { builder.Prepend("(?:", this); suffix += ")?"; } builder.Append("(?:" + separator + whitespace, this); builder.Append(InputContents.Value); builder.Append(suffix, this); return(builder); }
protected override NodeResultBuilder GetValue() { string suffix = GetSuffix(this); var builder = new NodeResultBuilder(ValueString(), this); builder.Append(suffix, this); return(builder); }
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 NodeResultBuilder GetValue() { var builder = new NodeResultBuilder(); foreach (var input in Inputs.Inputs) { builder.Append(input.Value); } return(builder); }
protected override NodeResultBuilder GetValue() { var builder = new NodeResultBuilder(); var inputs = Inputs.Inputs; string prefix = InputCapture.IsChecked ? "(" : "(?:"; builder.Append(prefix, this); if (inputs.Count > 0) { builder.Append(inputs.First().Value); foreach (var input in inputs.Skip(1)) { builder.Append("|", this); builder.Append(input.Value); } } builder.Append(")", this); return builder; }
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 NodeResultBuilder GetValue() { string result = InputAnchorType.Value switch { Mode.StartLine => "^", Mode.EndLine => "$", Mode.WordBoundary => "\\b", Mode.NotWordBoundary => "\\B", _ => "", }; var builder = new NodeResultBuilder(); builder.Append(result, this); return(builder); }
protected override NodeResultBuilder GetValue() { var builder = new NodeResultBuilder(InputContents.Value); //Simplify IntegerNode if needed if (InputContents.ConnectedNode is IntegerNode) { builder.StripNonCaptureGroup(); } 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(this); //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); }
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 && QuantifierNode.RequiresGroupToQuantify(_node)) { prefix += "(?:"; suffix += ")"; } //Add quantifier suffix += "?"; builder.Prepend(prefix, this); builder.Append(suffix, this); return(builder); }
protected override NodeResultBuilder GetValue() { var builder = new NodeResultBuilder(Input.Value); if (Input.ConnectedNode is OrNode) { builder.StripNonCaptureGroup(); } string prefix = InputGroupType.Value switch { Types.lookahead => "(?=", Types.lookbehind => "(?<=", Types.lookaheadNeg => "(?!", Types.lookbehindNeg => "(?<!", _ => "", }; builder.Prepend(prefix, this); builder.Append(")", this); return(builder); }
protected override NodeResultBuilder GetValue() { var builder = new NodeResultBuilder(); string open = InputOpenBracket.Value; string close = InputCloseBracket.Value; string openEscaped = open; string closeEscaped = close; if (!InputRegexInBrackets.Checked) { openEscaped = open.EscapeSpecialCharacters(); closeEscaped = close.EscapeSpecialCharacters(); } //Get expression for 'anything other than brackets' string notBrackets; if (open.Length <= 1 && close.Length <= 1) { //Use inverted CharSet if brackets are single chars notBrackets = $"[^{open.EscapeCharacters("[]")}{close.EscapeCharacters("[]")}]"; } else { //Use negative lookahead if brackets are expressions notBrackets = $"(?!{openEscaped}|{closeEscaped})."; } NodeResult betweenRec = InputContents.Connected ? InputContents.Value : new NodeResult(notBrackets, this); string groupName = InputGroupName.Value; string captureGroupName = InputCaptureName.Value; string openingGroup = InputNoBacktracking.Checked ? "(?>" : "(?:"; //Construct output builder.Append(openingGroup, this); { builder.Append($"(?<{groupName}>{openEscaped})", this); builder.Append("|", this); builder.Append($"(?<{captureGroupName}-{groupName}>{closeEscaped})", this); builder.Append("|", this); builder.Append(betweenRec); } builder.Append(")+", this); builder.Append($"(?({groupName})(?!))", this); if (InputEnclosingBrackets.Checked) { builder.Prepend(openEscaped, this); builder.Append(closeEscaped, this); } return(builder); }