You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ERE quantifiers are not validated: {m}, {m,} and {m,n} #289
When an ERE matching a single character or an ERE enclosed in parentheses is followed by an interval expression of the format "{m}", "{m,}", or "{m,n}", together with that interval expression it shall match what repeated consecutive occurrences of the ERE would match. The values of m and n are decimal integers in the range 0<=m<=n<={RE_DUP_MAX}, where m specifies the exact or minimum number of occurrences and n specifies the maximum number of occurrences. The expression "{m}" matches exactly m occurrences of the preceding ERE, "{m,}" matches at least m occurrences, and "{m,n}" matches any number of occurrences between m and n, inclusive.
When a BRE matching a single character, a subexpression, or a back-reference is followed by an interval expression of the format "\{m\}", "\{m,\}", or "\{m,n\}", together with that interval expression it shall match what repeated consecutive occurrences of the BRE would match. The values of m and n are decimal integers in the range 0 <=m<=n<={RE_DUP_MAX}, where m specifies the exact or minimum number of occurrences and n specifies the maximum number of occurrences. The expression "\{m\}" shall match exactly m occurrences of the preceding BRE, "\{m,\}" shall match at least m occurrences, and "\{m,n\}" shall match any number of occurrences between m and n, inclusive.'
We can overcome that by transforming {,} to asterisk * when parsing it (of course this is needed only for ERE - in case of BRE, the v{,} is parsed as a literal string). My only hesitation for that is that we alter the input pattern, but I can't find another way around.
Activity
e-kwsm commentedon Feb 5, 2026
uutils does not check expression in
{}: empty, nonintegral,and leading and trailing whitespaces.
LoukasPap commentedon Feb 9, 2026
Hello! @e-kwsm Can I give it a try or are you working on it? From what I've understood, we must basically add validity checks for the ERE quantifiers.
e-kwsm commentedon Feb 12, 2026
Hi, no I'm not addressing this issue.
LoukasPap commentedon Feb 15, 2026
Hello again. I think I've noticed a wrong behavior of BRE.
Like the ERE standard above, the same applies to BRE standard when using backslash
\in front of the{and}:https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/V1_chap09.html#tag_09_03_08:~:text=ab%22%2E-,When,inclusive
This can be seen in the sed docs too: https://www.gnu.org/software/sed/manual/sed.html#BRE-syntax
Example outputs:
e-kwsm commentedon Feb 15, 2026
Yes, sed must support
\{m\},\{m,\}and\{m,n\}BRE quantifiers (#288 (comment)).LoukasPap commentedon Feb 23, 2026
@e-kwsm While matching test cases' outputs of sed and uutils/sed, I found that case:
Running a
sedcommand like this returns everything:From my experiments,
x{,}is treated likex*(zero or more), thus capturing everything.This can be partially testified in the below example. It must capture a character
dfollowed by 0 or morev's. Only line 2 matches the pattern.The problem is, the
regexcrate does not acceptv{,}:Solution
We can overcome that by transforming
{,}to asterisk*when parsing it (of course this is needed only for ERE - in case of BRE, thev{,}is parsed as a literal string). My only hesitation for that is that we alter the input pattern, but I can't find another way around.e-kwsm commentedon Feb 23, 2026
Yeah, GNU and BSD sed’s seem to treat
{,}as{0,}viz*.