List Info

Thread: A christmas wish: simple notation for ratcheting (non-backtrack) regex




A christmas wish: simple notation for ratcheting (non-backtrack) regex
user name
2006-12-26 05:39:29
>>>>> "mark" == mark  <markmark.mielke.cc> writes:

mark> Are you asking for the same thing as the Java
"possessive quantifiers"?
mark> They use "+" to mean this already.

Yeah, OK.  I didn't think I was totally making this up. 

But it's even more interesting if it's to be compatible with
other
regex engines.  Cool.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. -
+1 503 777 0095
<merlynstonehenge.com> <URL:http://www.ston
ehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy,
etc. etc.
See PerlTraining.Stonehenge.com for onsite and
open-enrollment Perl training!
A christmas wish: simple notation for ratcheting (non-backtrack) regex
user name
2006-12-26 09:31:50
On 25 Dec 2006 21:39:29 -0800, Randal L. Schwartz
<merlynstonehenge.com> wrote:
> >>>>> "mark" == mark 
<markmark.mielke.cc> writes:
>
> mark> Are you asking for the same thing as the Java
"possessive quantifiers"?
> mark> They use "+" to mean this already.
>
> Yeah, OK.  I didn't think I was totally making this up.

>
> But it's even more interesting if it's to be compatible
with other
> regex engines.  Cool.

bleadperl has possessive quantifiers, thanks to Yves.
From perlre:

Possessive quantifiers are equivalent to putting the item
they are applied
to inside of one of these constructs. The following
equivalences apply:

    Quantifier Form     Bracketing Form
    ---------------     ---------------
    PAT*+               (?>PAT*)
    PAT++               (?>PAT+)
    PAT?+               (?>PAT?)
    PAT{min,max}+       (?>PAT{min,max})
A christmas wish: simple notation for ratcheting (non-backtrack) regex
user name
2006-12-26 09:36:38
>>>>> "Rafael" == Rafael
Garcia-Suarez <rgarciasuarezgmail.com> writes:

Rafael> bleadperl has possessive quantifiers, thanks to
Yves.
Rafael> From perlre:

Rafael> Possessive quantifiers are equivalent to putting
the item they are applied
Rafael> to inside of one of these constructs. The
following equivalences apply:

Rafael>     Quantifier Form     Bracketing Form
Rafael>     ---------------     ---------------
Rafael>     PAT*+               (?>PAT*)
Rafael>     PAT++               (?>PAT+)
Rafael>     PAT?+               (?>PAT?)
Rafael>     PAT{min,max}+       (?>PAT{min,max})

Christmas came early!

Does it work stacked with ? too, as in /PAT*?+/ ?

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. -
+1 503 777 0095
<merlynstonehenge.com> <URL:http://www.ston
ehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy,
etc. etc.
See PerlTraining.Stonehenge.com for onsite and
open-enrollment Perl training!
A christmas wish: simple notation for ratcheting (non-backtrack) regex
user name
2006-12-26 15:12:54
On 26 Dec 2006 01:36:38 -0800, Randal L. Schwartz
<merlynstonehenge.com> wrote:
> >>>>> "Rafael" == Rafael
Garcia-Suarez <rgarciasuarezgmail.com> writes:
>
> Rafael> bleadperl has possessive quantifiers, thanks
to Yves.
> Rafael> From perlre:
>
> Rafael> Possessive quantifiers are equivalent to
putting the item they are applied
> Rafael> to inside of one of these constructs. The
following equivalences apply:
>
> Rafael>     Quantifier Form     Bracketing Form
> Rafael>     ---------------     ---------------
> Rafael>     PAT*+               (?>PAT*)
> Rafael>     PAT++               (?>PAT+)
> Rafael>     PAT?+               (?>PAT?)
> Rafael>     PAT{min,max}+       (?>PAT{min,max})
>
> Christmas came early!
>
> Does it work stacked with ? too, as in /PAT*?+/ ?

No. From what i can see the following would be true if we
did:

PAT??+ and PAT*?+ are the same as matching nothing. Ie its
essentially a no-op.

PAT+?+ is the same as PAT

PAT{x,y}?+ is the same as PAT

Which to me says it doesnt add anything we cant do already,
and would
just make for more confusing patterns and therefor would be
code cruft
for minimal payback.

cheers,
Yves
-- 
perl -Mre=debug -e "/just|another|perl|hacker/"
A christmas wish: simple notation for ratcheting (non-backtrack) regex
user name
2006-12-26 18:44:00
>>>>> "demerphq" == demerphq 
<demerphqgmail.com> writes:

demerphq> No. From what i can see the following would be
true if we did:

demerphq> PAT??+ and PAT*?+ are the same as matching
nothing. Ie its essentially a no-op.

demerphq> PAT+?+ is the same as PAT

demerphq> PAT{x,y}?+ is the same as PAT

demerphq> Which to me says it doesnt add anything we cant
do already, and would
demerphq> just make for more confusing patterns and
therefor would be code cruft
demerphq> for minimal payback.

Ahh yes.  For the same reason that ? is the same as .

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. -
+1 503 777 0095
<merlynstonehenge.com> <URL:http://www.ston
ehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy,
etc. etc.
See PerlTraining.Stonehenge.com for onsite and
open-enrollment Perl training!
[1-5]

about | contact  Other archives ( Real Estate discussion Medical topics )