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-25 20:28:01
I know... I can already say (?= ... ) to prevent
backtracking once committed.

But it occurred to me the other day that just like
"?" following a quantifier
(?, *, +, , {m,n}) was formerly illegal, and therefore
used to introduce
the notion of laziness, that "+" is likewise
illegal.  How about making it so
that any quantifier (including lazily modified quantifers)
followed by "+"
means "never backtrack"?

So /a.*+b/ (or /a.{0,}+b/) would mean the same as /a(?=.*)b/
and /a.*?+b/ (or /a.{0,}?+b/) would mean the same as
/a(?=.*?)b/
and /a.++b/ (or /a.{1,}+b/) would means the same as
/a(?=.+)b/

Same functionality, just a much nicer notation.
"+" means "once I've
committed, that's it!".

Just a thought.

-- 
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 03:53:38
On Mon, Dec 25, 2006 at 12:28:01PM -0800, Randal L. Schwartz
wrote:
> But it occurred to me the other day that just like
"?" following a quantifier
> (?, *, +, , {m,n}) was formerly illegal, and
therefore used to introduce
> the notion of laziness, that "+" is likewise
illegal.  How about making it so
> that any quantifier (including lazily modified
quantifers) followed by "+"
> means "never backtrack"?
> ...
> Same functionality, just a much nicer notation.
"+" means "once I've
> committed, that's it!".

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

Cheers,
mark

-- 
markmielke.cc / markmncf.ca / markmnortel.com     __________________________
.  .  _  ._  . .   .__    .  . ._. .__ .   . . .__  |
Neighbourhood Coder
|/| |_| |_| |/    |_     |/|  |  |_  |   |/  |_   | 
|  | | | |  |    |__ .  |  | .|. |__ |__ |  |__  |
Ottawa, Ontario, Canada

  One ring to rule them all, one ring to find them, one ring
to bring them all
                       and in the darkness bind them...

                           http://mark.mielke.cc/

[1-2]

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