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:05:00 -0400	[thread overview]
Message-ID: <19bd5af70906031305q3a9b83f5v91ab6003ada74356@mail.gmail.com> (raw)
In-Reply-To: <19bd5af70906031301g78b732f5u3bfa260357309c35@mail.gmail.com>

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

btw, there is one site to play with RegExp
http://erik.eae.net/playground/regexp/regexp.html. Have fun.

a brief introduction can be found from here
http://en.wikipedia.org/wiki/Regular_expression.



On Wed, Jun 3, 2009 at 4:01 PM, Wu JIANG <albert.w.jiang@gmail.com> wrote:

> 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
>>
>>
>

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

  reply	other threads:[~2009-06-03 20:05 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 [this message]
2009-06-03 20:11   ` hugo rivera
2009-06-03 20:44     ` Wu JIANG
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=19bd5af70906031305q3a9b83f5v91ab6003ada74356@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).