Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RegexOptions.NonBacktracking #60607

Merged
merged 1 commit into from
Oct 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -303,4 +303,7 @@
<data name="UnterminatedComment" xml:space="preserve">
<value>Unterminated (?#...) comment.</value>
</data>
<data name="NotSupported_NonBacktrackingAndReplacementsWithSubstitutionsOfGroups" xml:space="preserve">
<value>Regex replacements with substitutions of groups are not supported with RegexOptions.NonBacktracking.</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,11 @@
<target state="translated">Výsledek nelze volat pro shodu, která se nezdařila.</target>
<note />
</trans-unit>
<trans-unit id="NotSupported_NonBacktrackingAndReplacementsWithSubstitutionsOfGroups">
<source>Regex replacements with substitutions of groups are not supported with RegexOptions.NonBacktracking.</source>
<target state="new">Regex replacements with substitutions of groups are not supported with RegexOptions.NonBacktracking.</target>
<note />
</trans-unit>
<trans-unit id="NotSupported_ReadOnlyCollection">
<source>Collection is read-only.</source>
<target state="translated">Kolekce je jen pro čtení.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,11 @@
<target state="translated">Das Ergebnis kann nicht für eine fehlgeschlagene Übereinstimmung aufgerufen werden.</target>
<note />
</trans-unit>
<trans-unit id="NotSupported_NonBacktrackingAndReplacementsWithSubstitutionsOfGroups">
<source>Regex replacements with substitutions of groups are not supported with RegexOptions.NonBacktracking.</source>
<target state="new">Regex replacements with substitutions of groups are not supported with RegexOptions.NonBacktracking.</target>
<note />
</trans-unit>
<trans-unit id="NotSupported_ReadOnlyCollection">
<source>Collection is read-only.</source>
<target state="translated">Die Sammlung ist schreibgeschützt.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,11 @@
<target state="translated">No se puede llamar al resultado si no se encuentra ninguna coincidencia.</target>
<note />
</trans-unit>
<trans-unit id="NotSupported_NonBacktrackingAndReplacementsWithSubstitutionsOfGroups">
<source>Regex replacements with substitutions of groups are not supported with RegexOptions.NonBacktracking.</source>
<target state="new">Regex replacements with substitutions of groups are not supported with RegexOptions.NonBacktracking.</target>
<note />
</trans-unit>
<trans-unit id="NotSupported_ReadOnlyCollection">
<source>Collection is read-only.</source>
<target state="translated">La colección es de sólo lectura.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,11 @@
<target state="translated">Le résultat ne peut pas être appelé sur un Match ayant échoué.</target>
<note />
</trans-unit>
<trans-unit id="NotSupported_NonBacktrackingAndReplacementsWithSubstitutionsOfGroups">
<source>Regex replacements with substitutions of groups are not supported with RegexOptions.NonBacktracking.</source>
<target state="new">Regex replacements with substitutions of groups are not supported with RegexOptions.NonBacktracking.</target>
<note />
</trans-unit>
<trans-unit id="NotSupported_ReadOnlyCollection">
<source>Collection is read-only.</source>
<target state="translated">La collection est en lecture seule.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,11 @@
<target state="translated">Impossibile chiamare Result su un Match non riuscito.</target>
<note />
</trans-unit>
<trans-unit id="NotSupported_NonBacktrackingAndReplacementsWithSubstitutionsOfGroups">
<source>Regex replacements with substitutions of groups are not supported with RegexOptions.NonBacktracking.</source>
<target state="new">Regex replacements with substitutions of groups are not supported with RegexOptions.NonBacktracking.</target>
<note />
</trans-unit>
<trans-unit id="NotSupported_ReadOnlyCollection">
<source>Collection is read-only.</source>
<target state="translated">La raccolta è di sola lettura.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,11 @@
<target state="translated">失敗した Match で Result を呼び出すことはできません。</target>
<note />
</trans-unit>
<trans-unit id="NotSupported_NonBacktrackingAndReplacementsWithSubstitutionsOfGroups">
<source>Regex replacements with substitutions of groups are not supported with RegexOptions.NonBacktracking.</source>
<target state="new">Regex replacements with substitutions of groups are not supported with RegexOptions.NonBacktracking.</target>
<note />
</trans-unit>
<trans-unit id="NotSupported_ReadOnlyCollection">
<source>Collection is read-only.</source>
<target state="translated">コレクションは読み取り専用です。</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,11 @@
<target state="translated">실패한 Match에서 결과를 호출할 수 없습니다.</target>
<note />
</trans-unit>
<trans-unit id="NotSupported_NonBacktrackingAndReplacementsWithSubstitutionsOfGroups">
<source>Regex replacements with substitutions of groups are not supported with RegexOptions.NonBacktracking.</source>
<target state="new">Regex replacements with substitutions of groups are not supported with RegexOptions.NonBacktracking.</target>
<note />
</trans-unit>
<trans-unit id="NotSupported_ReadOnlyCollection">
<source>Collection is read-only.</source>
<target state="translated">읽기 전용 컬렉션입니다.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,11 @@
<target state="translated">Nie można wywołać wyniku błędnego dopasowania.</target>
<note />
</trans-unit>
<trans-unit id="NotSupported_NonBacktrackingAndReplacementsWithSubstitutionsOfGroups">
<source>Regex replacements with substitutions of groups are not supported with RegexOptions.NonBacktracking.</source>
<target state="new">Regex replacements with substitutions of groups are not supported with RegexOptions.NonBacktracking.</target>
<note />
</trans-unit>
<trans-unit id="NotSupported_ReadOnlyCollection">
<source>Collection is read-only.</source>
<target state="translated">Kolekcja jest tylko do odczytu.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,11 @@
<target state="translated">Não é possível chamar resultado quando há falha na correspondência.</target>
<note />
</trans-unit>
<trans-unit id="NotSupported_NonBacktrackingAndReplacementsWithSubstitutionsOfGroups">
<source>Regex replacements with substitutions of groups are not supported with RegexOptions.NonBacktracking.</source>
<target state="new">Regex replacements with substitutions of groups are not supported with RegexOptions.NonBacktracking.</target>
<note />
</trans-unit>
<trans-unit id="NotSupported_ReadOnlyCollection">
<source>Collection is read-only.</source>
<target state="translated">A coleção é somente leitura.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,11 @@
<target state="translated">Вызов результата невозможен при сбойном соответствии.</target>
<note />
</trans-unit>
<trans-unit id="NotSupported_NonBacktrackingAndReplacementsWithSubstitutionsOfGroups">
<source>Regex replacements with substitutions of groups are not supported with RegexOptions.NonBacktracking.</source>
<target state="new">Regex replacements with substitutions of groups are not supported with RegexOptions.NonBacktracking.</target>
<note />
</trans-unit>
<trans-unit id="NotSupported_ReadOnlyCollection">
<source>Collection is read-only.</source>
<target state="translated">Данная коллекция предназначена только для чтения.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,11 @@
<target state="translated">Sonuç, başarısız Eşleştirmede çağrılamaz.</target>
<note />
</trans-unit>
<trans-unit id="NotSupported_NonBacktrackingAndReplacementsWithSubstitutionsOfGroups">
<source>Regex replacements with substitutions of groups are not supported with RegexOptions.NonBacktracking.</source>
<target state="new">Regex replacements with substitutions of groups are not supported with RegexOptions.NonBacktracking.</target>
<note />
</trans-unit>
<trans-unit id="NotSupported_ReadOnlyCollection">
<source>Collection is read-only.</source>
<target state="translated">Koleksiyon salt okunur.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,11 @@
<target state="translated">不能对失败的匹配调用结果。</target>
<note />
</trans-unit>
<trans-unit id="NotSupported_NonBacktrackingAndReplacementsWithSubstitutionsOfGroups">
<source>Regex replacements with substitutions of groups are not supported with RegexOptions.NonBacktracking.</source>
<target state="new">Regex replacements with substitutions of groups are not supported with RegexOptions.NonBacktracking.</target>
<note />
</trans-unit>
<trans-unit id="NotSupported_ReadOnlyCollection">
<source>Collection is read-only.</source>
<target state="translated">集合是只读的。</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,11 @@
<target state="translated">無法在已失敗的對應 (Match) 上呼叫結果。</target>
<note />
</trans-unit>
<trans-unit id="NotSupported_NonBacktrackingAndReplacementsWithSubstitutionsOfGroups">
<source>Regex replacements with substitutions of groups are not supported with RegexOptions.NonBacktracking.</source>
<target state="new">Regex replacements with substitutions of groups are not supported with RegexOptions.NonBacktracking.</target>
<note />
</trans-unit>
<trans-unit id="NotSupported_ReadOnlyCollection">
<source>Collection is read-only.</source>
<target state="translated">集合是唯讀的。</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ public enum RegexOptions
RightToLeft = 64,
ECMAScript = 256,
CultureInvariant = 512,
NonBacktracking = 1024,
}
public enum RegexParseError
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<root>
<?xml version="1.0" encoding="utf-8"?>
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
Expand Down Expand Up @@ -153,9 +154,6 @@
<data name="NotSupported_ReadOnlyCollection" xml:space="preserve">
<value>Collection is read-only.</value>
</data>
<data name="OnlyAllowedOnce" xml:space="preserve">
<value>This operation is only allowed once per object.</value>
</data>
<data name="PlatformNotSupported_CompileToAssembly" xml:space="preserve">
<value>This platform does not support writing compiled regular expressions to an assembly. Use RegexGeneratorAttribute with the regular expression source generator instead.</value>
</data>
Expand Down Expand Up @@ -225,4 +223,37 @@
<data name="UnterminatedComment" xml:space="preserve">
<value>Unterminated (?#...) comment.</value>
</data>
<data name="NotSupported_NonBacktrackingAndReplacementsWithSubstitutionsOfGroups" xml:space="preserve">
<value>Regex replacements with substitutions of groups are not supported with RegexOptions.NonBacktracking.</value>
</data>
<data name="NotSupported_NonBacktrackingConflictingOption" xml:space="preserve">
<value>RegexOptions.NonBacktracking is not supported in conjunction with RegexOptions.{0}.</value>
</data>
<data name="NotSupported_NonBacktrackingConflictingExpression" xml:space="preserve">
<value>RegexOptions.NonBacktracking is not supported in conjunction with expressions containing: '{0}'.</value>
</data>
<data name="ExpressionDescription_Backreference" xml:space="preserve">
<value>backreference (\\ number)</value>
</data>
<data name="ExpressionDescription_Conditional" xml:space="preserve">
<value>captured group conditional (?( name ) yes-pattern | no-pattern ) or (?( number ) yes-pattern| no-pattern )</value>
</data>
<data name="ExpressionDescription_PositiveLookaround" xml:space="preserve">
<value>positive lookahead (?= pattern) or positive lookbehind (?&lt;= pattern)</value>
</data>
<data name="ExpressionDescription_NegativeLookaround" xml:space="preserve">
<value>negative lookahead (?! pattern) or negative lookbehind (?&lt;! pattern)</value>
</data>
<data name="ExpressionDescription_ContiguousMatches" xml:space="preserve">
<value>contiguous matches (\\G)</value>
</data>
<data name="ExpressionDescription_AtomicSubexpressions" xml:space="preserve">
<value>atomic subexpressions (?&gt; pattern)</value>
</data>
<data name="ExpressionDescription_IfThenElse" xml:space="preserve">
<value>test conditional (?( test-pattern ) yes-pattern | no-pattern )</value>
</data>
<data name="ExpressionDescription_BalancingGroup" xml:space="preserve">
<value>balancing group (?&lt;name1-name2&gt;subexpression) or (?'name1-name2' subexpression)</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<Compile Include="System\Text\SegmentStringBuilder.cs" />
<Compile Include="System\Collections\HashtableExtensions.cs" />
<Compile Include="System\Collections\Generic\ValueListBuilder.Pop.cs" />
<Compile Include="System\Text\SegmentStringBuilder.cs" />
<Compile Include="System\Text\RegularExpressions\Capture.cs" />
<Compile Include="System\Text\RegularExpressions\CaptureCollection.cs" />
<Compile Include="System\Text\RegularExpressions\CollectionDebuggerProxy.cs" />
Expand All @@ -18,6 +18,7 @@
<Compile Include="System\Text\RegularExpressions\Regex.cs" />
<Compile Include="System\Text\RegularExpressions\Regex.Cache.cs" />
<Compile Include="System\Text\RegularExpressions\Regex.Match.cs" />
<Compile Include="System\Text\RegularExpressions\Regex.Debug.cs" />
<Compile Include="System\Text\RegularExpressions\Regex.Replace.cs" />
<Compile Include="System\Text\RegularExpressions\Regex.Split.cs" />
<Compile Include="System\Text\RegularExpressions\Regex.Timeout.cs" />
Expand All @@ -41,11 +42,52 @@
<Compile Include="System\Text\RegularExpressions\RegexTree.cs" />
<Compile Include="System\Text\RegularExpressions\RegexWriter.cs" />
<Compile Include="System\Text\RegularExpressions\ThrowHelper.cs" />
<!-- Files that enable compiled feature -->
<!-- RegexOptions.Compiled -->
<Compile Include="System\Text\RegularExpressions\CompiledRegexRunnerFactory.cs" />
<Compile Include="System\Text\RegularExpressions\CompiledRegexRunner.cs" />
<Compile Include="System\Text\RegularExpressions\RegexCompiler.cs" />
<Compile Include="System\Text\RegularExpressions\RegexLWCGCompiler.cs" />
<!-- RegexOptions.NonBacktracking -->
<Compile Include="System\Text\RegularExpressions\Symbolic\BooleanClassifier.cs" />
<Compile Include="System\Text\RegularExpressions\Symbolic\CharKind.cs" />
<Compile Include="System\Text\RegularExpressions\Symbolic\DfaMatchingState.cs" />
<Compile Include="System\Text\RegularExpressions\Symbolic\MintermClassifier.cs" />
<Compile Include="System\Text\RegularExpressions\Symbolic\RegexNodeToSymbolicConverter.cs" />
<Compile Include="System\Text\RegularExpressions\Symbolic\StackHelper.cs" />
<Compile Include="System\Text\RegularExpressions\Symbolic\SymbolicMatch.cs" />
<Compile Include="System\Text\RegularExpressions\Symbolic\SymbolicNFA.cs" />
<Compile Include="System\Text\RegularExpressions\Symbolic\SymbolicRegexBuilder.cs" />
<Compile Include="System\Text\RegularExpressions\Symbolic\SymbolicRegexNode.cs" />
<Compile Include="System\Text\RegularExpressions\Symbolic\SymbolicRegexKind.cs" />
<Compile Include="System\Text\RegularExpressions\Symbolic\SymbolicRegexInfo.cs" />
<Compile Include="System\Text\RegularExpressions\Symbolic\SymbolicRegexMatcher.cs" />
<Compile Include="System\Text\RegularExpressions\Symbolic\SymbolicRegexRunner.cs" />
<Compile Include="System\Text\RegularExpressions\Symbolic\SymbolicRegexRunnerFactory.cs" />
<Compile Include="System\Text\RegularExpressions\Symbolic\SymbolicRegexSampler.cs" />
<Compile Include="System\Text\RegularExpressions\Symbolic\SymbolicRegexSet.cs" />
<Compile Include="System\Text\RegularExpressions\Symbolic\TransitionRegex.cs" />
<Compile Include="System\Text\RegularExpressions\Symbolic\TransitionRegexKind.cs" />
<Compile Include="System\Text\RegularExpressions\Symbolic\Algebras\BDD.cs" />
<Compile Include="System\Text\RegularExpressions\Symbolic\Algebras\BDDAlgebra.cs" />
<Compile Include="System\Text\RegularExpressions\Symbolic\Algebras\BDDRangeConverter.cs" />
<Compile Include="System\Text\RegularExpressions\Symbolic\Algebras\BV.cs" />
<Compile Include="System\Text\RegularExpressions\Symbolic\Algebras\BV64Algebra.cs" />
<Compile Include="System\Text\RegularExpressions\Symbolic\Algebras\BVAlgebra.cs" />
<Compile Include="System\Text\RegularExpressions\Symbolic\Algebras\CharSetSolver.cs" />
<Compile Include="System\Text\RegularExpressions\Symbolic\Algebras\IBooleanAlgebra.cs" />
<Compile Include="System\Text\RegularExpressions\Symbolic\Algebras\ICharAlgebra.cs" />
<Compile Include="System\Text\RegularExpressions\Symbolic\Algebras\MintermGenerator.cs" />
<Compile Include="System\Text\RegularExpressions\Symbolic\Dgml\DgmlWriter.cs" />
<Compile Include="System\Text\RegularExpressions\Symbolic\Dgml\IAutomaton.cs" />
<Compile Include="System\Text\RegularExpressions\Symbolic\Dgml\Move.cs" />
<Compile Include="System\Text\RegularExpressions\Symbolic\Dgml\RegexAutomaton.cs" />
<Compile Include="System\Text\RegularExpressions\Symbolic\Unicode\GeneratorHelper.cs" />
<Compile Include="System\Text\RegularExpressions\Symbolic\Unicode\IgnoreCaseRelation.cs" />
<Compile Include="System\Text\RegularExpressions\Symbolic\Unicode\IgnoreCaseRelationGenerator.cs" />
<Compile Include="System\Text\RegularExpressions\Symbolic\Unicode\IgnoreCaseTransformer.cs" />
<Compile Include="System\Text\RegularExpressions\Symbolic\Unicode\UnicodeCategoryRanges.cs" />
<Compile Include="System\Text\RegularExpressions\Symbolic\Unicode\UnicodeCategoryRangesGenerator.cs" />
<Compile Include="System\Text\RegularExpressions\Symbolic\Unicode\UnicodeCategoryTheory.cs" />
<!-- Common or Common-branched source files -->
<Compile Include="$(CommonPath)System\HexConverter.cs" Link="Common\System\HexConverter.cs" />
<Compile Include="$(CommonPath)System\NotImplemented.cs" Link="Common\System\NotImplemented.cs" />
Expand All @@ -60,7 +102,7 @@
<Reference Include="System.Runtime" />
<Reference Include="System.Runtime.Extensions" />
<Reference Include="System.Threading" />
<!-- References required for compiled feature -->
<!-- References required for RegexOptions.Compiled -->
<Reference Include="System.Reflection.Emit" />
<Reference Include="System.Reflection.Emit.ILGeneration" />
<Reference Include="System.Reflection.Emit.Lightweight" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public virtual string Result(string replacement)
}

// Gets the weakly cached replacement helper or creates one if there isn't one already.
RegexReplacement repl = RegexReplacement.GetOrCreate(regex._replref!, replacement, regex.caps!, regex.capsize, regex.capnames!, regex.roptions);
RegexReplacement repl = RegexReplacement.GetOrCreate(regex.RegexReplacementWeakReference, replacement, regex.caps!, regex.capsize, regex.capnames!, regex.roptions);
SegmentStringBuilder segments = SegmentStringBuilder.Create();
repl.ReplacementImpl(ref segments, this);
return segments.ToString();
Expand Down
Loading