19 writes to Str
System.Text.RegularExpressions.Generator (19)
src\libraries\System.Text.RegularExpressions\src\System\Text\RegularExpressions\RegexNode.cs (19)
68Str = str; 190Str = null; 198Str = new string(Ch, N); 964Str = null; 969Str = null; 979Str = null; 997Str = RegexCharClass.AnyClass; 1002Str = RegexCharClass.NotDigitClass; 1005Str = RegexCharClass.NotSpaceClass; 1008Str = RegexCharClass.NotWordClass; 1156prev.Str = prevCharClass.ToStringClass(); 1449node.Str = null; 1455node.Str = null; 1459node.Str = node.Str.Substring(startingSpan.Length); 1779prev.Str = prev.Ch.ToString(); 1782prev.Str = (optionsAt & RegexOptions.RightToLeft) == 0 ? 1925nextNode.Str = null; 1929nextNode.Str = nextNode.Str.Substring(matchingCharsInMulti); 3124Str = new string(Ch, max);
146 references to Str
System.Text.RegularExpressions.Generator (146)
RegexGenerator.Emitter.cs (26)
783writer.WriteLine($"int end = base.runtextpos = start {(!rtl ? "+" : "-")} {(root.Kind == RegexNodeKind.Multi ? root.Str!.Length : 1)};"); 1508writer.Write($"// The pattern begins with an atomic loop for {DescribeSet(target.LoopNode.Str!)}, followed by "); 1556using (EmitBlock(writer, $"while ((uint)prev < (uint)slice.Length && {MatchCharacterClass("slice[prev]", target.LoopNode.Str!, negate: false, additionalDeclarations, requiredHelpers)})")) 1894int numChars = RegexCharClass.GetSetChars(startingLiteralNode.Str!, setChars); 1977return multi.Str!.Length == 2 ? 1978new(RegexNodeKind.One, multi.Options, multi.Str[1]) : 1979new(RegexNodeKind.Multi, multi.Options, multi.Str.Substring(1)); 3121EmitMultiCharString(child.Str!, emitLengthCheck: false, clauseOnly: true, rightToLeft: false); 3211MatchCharacterClass(expr, node.Str!, negate: true, additionalDeclarations, requiredHelpers) : 3351Debug.Assert(node.Str is not null); 3352EmitMultiCharString(node.Str, emitLengthCheck, clauseOnly: false, (node.Options & RegexOptions.RightToLeft) != 0); 3706node.Str == RegexCharClass.AnyClass && 4115else if (node.IsSetFamily && node.Str == RegexCharClass.AnyClass) 4230if (node.IsSetFamily && maxIterations == int.MaxValue && node.Str == RegexCharClass.AnyClass) 4242MatchCharacterClass(expr, node.Str!, negate: false, additionalDeclarations, requiredHelpers) : 4253else if (node.IsSetFamily && maxIterations == int.MaxValue && node.Str == RegexCharClass.AnyClass) 4287MatchCharacterClass(expr, node.Str!, negate: false, additionalDeclarations, requiredHelpers) : 4350MatchCharacterClass(expr, node.Str!, negate: false, additionalDeclarations, requiredHelpers) : 5019indexOfExpr = $"{last}IndexOf({Literal(node.Str!)})"; 5020literalLength = node.Str!.Length; 5040bool negated = RegexCharClass.IsNegated(node.Str) ^ negate; 5044if (RegexCharClass.TryGetSingleRange(node.Str, out char lowInclusive, out char highInclusive) && 5059setChars = setChars.Slice(0, RegexCharClass.GetSetChars(node.Str, setChars)); 5556RegexNodeKind.Multi => $"Match the string {Literal(node.Str!)}{direction}.", 5567RegexNodeKind.Set => $"Match {DescribeSet(node.Str!)}{direction}.", 5568RegexNodeKind.Setloop or RegexNodeKind.Setloopatomic or RegexNodeKind.Setlazy => $"Match {DescribeSet(node.Str!)} {DescribeLoop(node, rm)}{direction}.",
src\libraries\System.Text.RegularExpressions\src\System\Text\RegularExpressions\RegexNode.cs (95)
95new RegexNode(Kind, Options, Str!) : 332Debug.Assert(node.Str is not null, "Expect non-null multi string"); 333Debug.Assert(node.Str.Length >= 2, $"Expected {node.Str} to be at least two characters"); 340Debug.Assert(!string.IsNullOrEmpty(node.Str), $"Expected non-null, non-empty string for {node.Kind}."); 344Debug.Assert(node.Str is null, $"Expected null string for {node.Kind}, got \"{node.Str}\"."); 959Debug.Assert(!string.IsNullOrEmpty(Str)); 961if (RegexCharClass.IsEmpty(Str)) 966else if (RegexCharClass.IsSingleton(Str)) 968Ch = RegexCharClass.SingletonChar(Str); 976else if (RegexCharClass.IsSingletonInverse(Str)) 978Ch = RegexCharClass.SingletonChar(Str); 988switch (Str) 1113if (!wasLastSet || optionsLast != optionsAt || lastNodeCannotMerge || !RegexCharClass.IsMergeable(at.Str!)) 1116lastNodeCannotMerge = !RegexCharClass.IsMergeable(at.Str!); 1142prevCharClass = RegexCharClass.Parse(prev.Str!); 1151RegexCharClass atCharClass = RegexCharClass.Parse(at.Str!); 1232required.Str != other.Str) 1355scoped ReadOnlySpan<char> startingSpan = startingNode.Str.AsSpan(); 1391Debug.Assert(startingNode.Str!.Length > 0); 1393int minLength = Math.Min(startingSpan.Length, startingNode.Str.Length); 1395while (c < minLength && startingSpan[c] == startingNode.Str[c]) c++; 1445Debug.Assert(node.Str.AsSpan().StartsWith(startingSpan, StringComparison.Ordinal)); 1446if (node.Str!.Length == startingSpan.Length) 1451else if (node.Str.Length - 1 == startingSpan.Length) 1454node.Ch = node.Str[node.Str.Length - 1]; 1459node.Str = node.Str.Substring(startingSpan.Length); 1501return IsOneFamily ? Ch : Str![0]; 1552if (RegexCharClass.IsNegated(startingLiteralNode.Str!) || 1553(numChars = RegexCharClass.GetSetChars(startingLiteralNode.Str!, setChars)) == 0) 1626if (RegexCharClass.TryGetSingleRange(node.Str!, out char lowInclusive, out char highInclusive) && 1630return new StartingLiteralData(range: (lowInclusive, highInclusive), negated: RegexCharClass.IsNegated(node.Str!)); 1635if ((numChars = RegexCharClass.GetSetChars(node.Str!, setChars)) != 0) 1637return new StartingLiteralData(setChars: setChars.Slice(0, numChars).ToString(), negated: RegexCharClass.IsNegated(node.Str!)); 1642return new StartingLiteralData(@string: node.Str); 1783((at.Kind == RegexNodeKind.One) ? $"{prev.Str}{at.Ch}" : prev.Str + at.Str) : 1784((at.Kind == RegexNodeKind.One) ? $"{at.Ch}{prev.Str}" : at.Str + prev.Str); 1848case RegexNodeKind.Setloop or RegexNodeKind.Setloopatomic or RegexNodeKind.Setlazy when nextNode.Kind == currentNode.Kind && currentNode.Str == nextNode.Str: 1875case RegexNodeKind.Setloop or RegexNodeKind.Setlazy when nextNode.Kind == RegexNodeKind.Set && currentNode.Str == nextNode.Str: 1892currentNode.Ch == nextNode.Str![0]: 1897while (matchingCharsInMulti < nextNode.Str.Length && currentNode.Ch == nextNode.Str[matchingCharsInMulti]) 1912if (nextNode.Str.Length == matchingCharsInMulti) 1920Debug.Assert(matchingCharsInMulti < nextNode.Str.Length); 1921if (nextNode.Str.Length - matchingCharsInMulti == 1) 1924nextNode.Ch = nextNode.Str[nextNode.Str.Length - 1]; 1929nextNode.Str = nextNode.Str.Substring(matchingCharsInMulti); 1943case RegexNodeKind.Set when (nextNode.Kind is RegexNodeKind.Setloop or RegexNodeKind.Setloopatomic or RegexNodeKind.Setlazy) && currentNode.Str == nextNode.Str: 1957case RegexNodeKind.Set when nextNode.Kind == RegexNodeKind.Set && currentNode.Str == nextNode.Str: 2424case RegexNodeKind.Set when !RegexCharClass.CharInClass(node.Ch, subsequent.Str!): 2427case RegexNodeKind.Setlazy or RegexNodeKind.Setloop or RegexNodeKind.Setloopatomic when subsequent.M > 0 && !RegexCharClass.CharInClass(node.Ch, subsequent.Str!): 2428case RegexNodeKind.Multi when node.Ch != subsequent.Str![0]: 2439case RegexNodeKind.Setlazy or RegexNodeKind.Setloop or RegexNodeKind.Setloopatomic when subsequent.M == 0 && !RegexCharClass.CharInClass(node.Ch, subsequent.Str!): 2454case RegexNodeKind.Multi when node.Ch == subsequent.Str![0]: 2471case RegexNodeKind.One when !RegexCharClass.CharInClass(subsequent.Ch, node.Str!): 2472case RegexNodeKind.Set when !RegexCharClass.MayOverlap(node.Str!, subsequent.Str!): 2473case RegexNodeKind.Onelazy or RegexNodeKind.Oneloop or RegexNodeKind.Oneloopatomic when subsequent.M > 0 && !RegexCharClass.CharInClass(subsequent.Ch, node.Str!): 2474case RegexNodeKind.Setlazy or RegexNodeKind.Setloop or RegexNodeKind.Setloopatomic when subsequent.M > 0 && !RegexCharClass.MayOverlap(node.Str!, subsequent.Str!): 2475case RegexNodeKind.Multi when !RegexCharClass.CharInClass(subsequent.Str![0], node.Str!): 2477case RegexNodeKind.EndZ or RegexNodeKind.Eol when !RegexCharClass.CharInClass('\n', node.Str!): 2478case RegexNodeKind.Boundary when node.M > 0 && RegexCharClass.IsKnownWordClassSubset(node.Str!): 2479case RegexNodeKind.NonBoundary when node.M > 0 && node.Str is RegexCharClass.NotWordClass or RegexCharClass.NotDigitClass: 2480case RegexNodeKind.ECMABoundary when node.M > 0 && node.Str is RegexCharClass.ECMAWordClass or RegexCharClass.ECMADigitClass: 2481case RegexNodeKind.NonECMABoundary when node.M > 0 && node.Str is RegexCharClass.NotECMAWordClass or RegexCharClass.NotDigitClass: 2484case RegexNodeKind.Onelazy or RegexNodeKind.Oneloop or RegexNodeKind.Oneloopatomic when subsequent.M == 0 && !RegexCharClass.CharInClass(subsequent.Ch, node.Str!): 2485case RegexNodeKind.Setlazy or RegexNodeKind.Setloop or RegexNodeKind.Setloopatomic when subsequent.M == 0 && !RegexCharClass.MayOverlap(node.Str!, subsequent.Str!): 2519case RegexNodeKind.Set when !MayOverlapStartingOrEndingSet(subsequent.Str!): 2521case RegexNodeKind.Setlazy or RegexNodeKind.Setloop or RegexNodeKind.Setloopatomic when subsequent.M > 0 && !MayOverlapStartingOrEndingSet(subsequent.Str!): 2522case RegexNodeKind.Multi when !CharInStartingOrEndingSet(subsequent.Str![0]): 2532case RegexNodeKind.Setlazy or RegexNodeKind.Setloop or RegexNodeKind.Setloopatomic when subsequent.M == 0 && !MayOverlapStartingOrEndingSet(subsequent.Str!): 2714return Str!.Length; 2827return Str!.Length; 2990if (!Ascii.IsValid(child.Str) || 2991RegexCharClass.ParticipatesInCaseConversion(child.Str.AsSpan())) 2996vsb.Append(child.Str); 3003if (!RegexCharClass.SetContainsAsciiOrdinalIgnoreCaseCharacter(child.Str!, twoChars)) 3261[MemberNotNullWhen(true, nameof(Str))] 3342foreach (char c in Str!) 3352sb.Append(' ').Append(RegexCharClass.DescribeSet(Str!));
src\libraries\System.Text.RegularExpressions\src\System\Text\RegularExpressions\RegexNodeKind.cs (5)
22/// <remarks>The <see cref="RegexCharClass"/> set string is specified in <see cref="RegexNode.Str"/>.</remarks> 26/// <remarks>The characters are specified in <see cref="RegexNode.Str"/>. This is purely a representational optimization, equivalent to multiple <see cref="One"/> nodes concatenated together.</remarks> 40/// <remarks>The <see cref="RegexCharClass"/> set string is specified in <see cref="RegexNode.Str"/>, the minimum number of iterations in <see cref="RegexNode.M"/>, and the maximum number of iterations in <see cref="RegexNode.N"/>.</remarks> 53/// <remarks>The <see cref="RegexCharClass"/> set string is specified in <see cref="RegexNode.Str"/>, the minimum number of iterations in <see cref="RegexNode.M"/>, and the maximum number of iterations in <see cref="RegexNode.N"/>.</remarks> 71/// The <see cref="RegexCharClass"/> set string is specified in <see cref="RegexNode.Str"/>, the minimum number of iterations in <see cref="RegexNode.M"/>, and the maximum number of iterations in <see cref="RegexNode.N"/>.
src\libraries\System.Text.RegularExpressions\src\System\Text\RegularExpressions\RegexPrefixAnalyzer.cs (20)
129sb.Append(node.Str); 136foreach (char c in node.Str!) 156case RegexNodeKind.Set or RegexNodeKind.Setloop or RegexNodeKind.Setlazy or RegexNodeKind.Setloopatomic when !RegexCharClass.IsNegated(node.Str!): // negated sets are too complex to analyze 158int charCount = RegexCharClass.GetSetChars(node.Str!, setChars); 197if (!RegexCharClass.SetContainsAsciiOrdinalIgnoreCaseCharacter(node.Str!, setChars)) 428vsb.Append(node.Str); 623string s = node.Str!; 636results.Add(new RegexFindOptimizations.FixedDistanceSet(null, node.Str!, distance++)); 647results.Add(new RegexFindOptimizations.FixedDistanceSet(null, node.Str!, distance++)); 986cc = RegexCharClass.Parse(node.Str!); 989else if (cc.CanMerge && RegexCharClass.Parse(node.Str!) is { CanMerge: true } setCc) 1005cc.AddChar(node.Str![firstChar ? 0 : node.Str.Length - 1]); 1184RegexCharClass.CharInClass(prefix[0], firstChild.Str!) ? null : 1205if (RegexCharClass.CharInClass((char)(ordinalCaseInsensitivePrefix[0] | 0x20), firstChild.Str!) || 1206RegexCharClass.CharInClass((char)(ordinalCaseInsensitivePrefix[0] & ~0x20), firstChild.Str!)) 1211else if (RegexCharClass.CharInClass(ordinalCaseInsensitivePrefix[0], firstChild.Str!)) 1232!RegexCharClass.IsNegated(nextChild.Str!) && 1236chars = chars.Slice(0, RegexCharClass.GetSetChars(nextChild.Str!, chars)); 1241if (RegexCharClass.CharInClass(c, firstChild.Str!))