unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Lennart Borgman <lennart.borgman@gmail.com>
Cc: Leo <sdl.web@gmail.com>, Drew Adams <drew.adams@oracle.com>,
	emacs-devel@gnu.org
Subject: Re: `completion-in-region'
Date: Mon, 12 Apr 2010 09:10:36 -0400	[thread overview]
Message-ID: <jwvaat8x1i9.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <z2me01d8a51004120246q1ea43e11m76e967f32886531c@mail.gmail.com> (Lennart Borgman's message of "Mon, 12 Apr 2010 11:46:33 +0200")

>>>> If you use ".*?a.*?b.*?c", then yes it gives the
>>>> same matches but it also has the same O(N^3) worst case.
>>> This is not the right place perhaps to educate me on this, but to me
>>> it looks like just three linear searches with the summed length for
>>> the searches equal to that of the candidate strings. Is not that O(N)?
>> When matched against "ababab", it will do the following:
>> - search for a in the string.
>> - for each match of a, search for b in the remaining string.
> I do not understand the "for each" here. I thought that since ".*?" is
> greedy that means that only the first "a" could match.

No, what the question mark means is that it will first try to match the
first a, rather than first try to match the last a.

Fundamentally, our | is an ordered alternation operator (i.e. first try
the lefthand side and if that fails, try the righthandside), and the
repetition operators are defined as:

   E*  = (EE*|)
   E*?   (|EE*?)


-- Stefan




  reply	other threads:[~2010-04-12 13:10 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-06 14:37 `completion-in-region' Leo
2010-04-09  3:05 ` `completion-in-region' Stefan Monnier
2010-04-11 12:56   ` `completion-in-region' Leo
2010-04-11 15:32     ` `completion-in-region' Stefan Monnier
2010-04-11 18:05       ` `completion-in-region' Drew Adams
2010-04-11 19:44         ` `completion-in-region' Stefan Monnier
2010-04-11 19:56           ` `completion-in-region' Drew Adams
2010-04-11 20:49             ` `completion-in-region' Stefan Monnier
2010-04-11 21:13               ` `completion-in-region' Drew Adams
2010-04-11 20:08           ` `completion-in-region' Lennart Borgman
2010-04-11 20:51             ` `completion-in-region' Stefan Monnier
2010-04-11 21:06               ` `completion-in-region' Lennart Borgman
2010-04-12  2:10                 ` `completion-in-region' Stefan Monnier
2010-04-12  9:46                   ` `completion-in-region' Lennart Borgman
2010-04-12 13:10                     ` Stefan Monnier [this message]
2010-04-12 14:50                     ` `completion-in-region' Davis Herring
2010-04-11 21:12             ` `completion-in-region' Drew Adams
2010-04-12 15:36       ` `completion-in-region' Leo
2010-04-12 18:10         ` `completion-in-region' Stefan Monnier
2010-04-12 15:51       ` `completion-in-region' Leo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvaat8x1i9.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=drew.adams@oracle.com \
    --cc=emacs-devel@gnu.org \
    --cc=lennart.borgman@gmail.com \
    --cc=sdl.web@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).