9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Wu JIANG <albert.w.jiang@gmail.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: Re: [9fans] plan 9 regexp
Date: Wed,  3 Jun 2009 16:44:10 -0400	[thread overview]
Message-ID: <19bd5af70906031344m3e8c6f4dndbcaa8a52d6072c0@mail.gmail.com> (raw)
In-Reply-To: <138575260906031311o10ac5d59qa8366b89e56b1ff@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1943 bytes --]

Sorry, I misunderstood your question in the first place. I think one example
can be good to show how ``?'' is useful somehow in grep.

Suppose I have a file, I want to find out a keyword ``produce'', but I know
that the word ``produced'' might also be the word that I am interested (stem
process in information retrieval or nlp). So I use the pattern "produced?"
to find all the words useful to me.

I hope this can be helpful at least a little bit. :-)

On Wed, Jun 3, 2009 at 4:11 PM, hugo rivera <uair00@gmail.com> wrote:

> you are right, but the original post read
>
> > grep 'a+bb?'
>
> so you get at least one 'a' and one or two 'b'.
>
> 2009/6/3 Wu JIANG <albert.w.jiang@gmail.com>:
> > actually, a+ means at least one 'a', b? means zero or one 'b'.
> >
> > On Wed, Jun 3, 2009 at 10:56 AM, hugo rivera <uair00@gmail.com> wrote:
> >>
> >> Hello,
> >> I am experimenting with some regexp implementations (namely the one
> >> from "the practice of programming") and I am a little disoriented by
> >> the use of the '?' operator in plan 9's grep:
> >> say I have the following input
> >>
> >> aaaabbb
> >> ab
> >> aaaab
> >> bb
> >> b
> >> aaabb
> >> aaaa
> >>
> >> which I feed into grep with
> >>
> >> grep 'a+bb?'
> >>
> >> which should match at least one 'a' followed by one or two 'b'. So,
> >> grep's output is
> >>
> >> aaaabbb
> >> ab
> >> aaaab
> >> aaabb
> >>
> >> which really surprised me at first, since I wasn't expecting the first
> >> line. After some thought, I realized that the 'aaaab' and the 'aaaabb'
> >> patterns, contained in the first line of input, match the regexp, so
> >> grep prints the line.
> >> But then, how exactly the '?' operator is useful for grep? I was
> >> thinking that it was good to filter lines that contain more characters
> >> that desired, but it is not.
> >> Saludos
> >> --
> >> Hugo
> >>
> >
> >
>
>
>
> --
> Hugo
>
>

[-- Attachment #2: Type: text/html, Size: 2884 bytes --]

  reply	other threads:[~2009-06-03 20:44 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-03 14:56 hugo rivera
2009-06-03 16:21 ` Rodolfo (kix)
2009-06-03 17:34   ` erik quanstrom
2009-06-03 17:46     ` Rob Pike
2009-06-03 18:05       ` hugo rivera
2009-06-03 16:50 ` yy
2009-06-03 16:51 ` Russ Cox
2009-06-03 17:19 ` Enrique Soriano
2009-06-03 20:01 ` Wu JIANG
2009-06-03 20:05   ` Wu JIANG
2009-06-03 20:11   ` hugo rivera
2009-06-03 20:44     ` Wu JIANG [this message]
2009-06-03 20:49       ` hugo rivera
2009-06-03 23:32 ` J.R. Mauro
2009-06-03 23:41 Francisco J Ballesteros
2009-06-03 23:56 ` erik quanstrom
2009-06-04  1:22   ` J.R. Mauro
2009-06-04 11:43     ` Martin Neubauer
2009-06-04 19:23       ` J. R. Mauro
2009-06-04 19:27         ` erik quanstrom
2009-06-04 21:54           ` J.R. Mauro
2009-06-05 18:12             ` erik quanstrom
2009-06-13 18:29           ` J.R. Mauro
2009-06-04 21:35   ` Dan Cross
2009-06-04 22:36     ` Charles Forsyth
2009-06-05  0:05       ` Dan Cross
2009-06-06 17:55         ` Ori Bernstein
2009-06-07 17:11           ` erik quanstrom
2009-06-07 21:31         ` Russ Cox
2009-06-05  0:07     ` Dan Cross

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

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

  git send-email \
    --in-reply-to=19bd5af70906031344m3e8c6f4dndbcaa8a52d6072c0@mail.gmail.com \
    --to=albert.w.jiang@gmail.com \
    --cc=9fans@9fans.net \
    /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.
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 NNTP newsgroup(s).