dotnet/runtime

Regex - Support Possessive Quantifiers

Open

#24,381 opened on Dec 7, 2017

View on GitHub
 (9 comments) (5 reactions) (0 assignees)C# (5,445 forks)batch import
area-System.Text.RegularExpressionsenhancementhelp wanted

Repository metrics

Stars
 (17,886 stars)
PR merge metrics
 (Avg merge 12d 11h) (661 merged PRs in 30d)

Description

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.

Contributor guide