dotnet/runtime

Regex - Support Possessive Quantifiers

Open

#24.381 aperta il 7 dic 2017

Vedi su GitHub
 (9 commenti) (5 reazioni) (0 assegnatari)C# (5445 fork)batch import
area-System.Text.RegularExpressionsenhancementhelp wanted

Metriche repository

Star
 (17.886 star)
Metriche merge PR
 (Merge medio 12g 11h) (661 PR mergiate in 30 g)

Descrizione

Current popular regex engines like java.util.regex or PCRE support greedy, lazy and possessive quantifiers. The current .NET regex engine does only support the former two. Though possessive quantifiers are syntactic sugar and can be mimicked with atomic grouping today, consider supporting them as they gained popularity over the last years.

Abstract: Possessive quantifiers work the same as greedy quantifiers but without backtracking on the input string. That means that the following pattern D++[A-Z]+ matches the input string DDDDE but not DDDD.

Guida contributor