[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]
Re: [perl #56526] m/a{1,0}/ compiles but doesn't match a literal string
2008/7/2 via RT Michael Cartmell <perlbug-followup@perl.org>:
> The regular expression /a{2,1}/ fails to compiles the the error
> Can't do {n,m} with n > m in regex; marked by <-- HERE in m/a{2,1} <--
> HERE / at -e line 1.
>
> The regular expression /a{2,-1}/ compiles and matches a literal "a{2,-1}".
>
> The regex /a{2,0}/, however, compiles into a form that must match at least
> two "a"s but then fails. I'm guessing because at the point it has
> matched two
> "a"s it must also match no more than zero.
>
> michael@lnx-main:perl-5.10.x> perl -Mre=debug -E'say "matched" if "aaa"
> =~ qr/a{2,0}/'
> Compiling REx "a{2,0}"
> Final program:
> 1: CURLY {2,0} (5)
> 3: EXACT <a> (0)
> 5: END (0)
> anchored "aa" at 0 (checking anchored) minlen 2
> Guessing start of match in sv for REx "a{2,0}" against "aaa"
> Found anchored substr "aa" at offset 0...
> Guessed: match at offset 0
> Matching REx "a{2,0}" against "aaa"
> 0 <> <aaa> | 1:CURLY {2,0}(5)
> failed...
> 1 <a> <aa> | 1:CURLY {2,0}(5)
> failed...
> Match failed
> Freeing REx: "a{2,0}"
>
> The choices appear to be
> 1. document this as the expected behaviour.
> 2. match a literal "a{2,0}", consistent with /a{2,-0}/.
> 3. make /a{2,0}/ an error, consistent with /a{2,1}/.
>
> This patch make /a{2,0}/ an error and adds a test.
Thanks, applied to bleadperl.
[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]