From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: <138575260906031311o10ac5d59qa8366b89e56b1ff@mail.gmail.com> References: <138575260906030756u287ecfe6x5085e3d11ed0a367@mail.gmail.com> <19bd5af70906031301g78b732f5u3bfa260357309c35@mail.gmail.com> <138575260906031311o10ac5d59qa8366b89e56b1ff@mail.gmail.com> Date: Wed, 3 Jun 2009 16:44:10 -0400 Message-ID: <19bd5af70906031344m3e8c6f4dndbcaa8a52d6072c0@mail.gmail.com> From: Wu JIANG To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: multipart/alternative; boundary=0016364ece88ad2d52046b77b8d0 Subject: Re: [9fans] plan 9 regexp Topicbox-Message-UUID: 040eeaf2-ead5-11e9-9d60-3106f5b1d025 --0016364ece88ad2d52046b77b8d0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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 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 : > > actually, a+ means at least one 'a', b? means zero or one 'b'. > > > > On Wed, Jun 3, 2009 at 10:56 AM, hugo rivera 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 > > --0016364ece88ad2d52046b77b8d0 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Sorry, I misunderstood your question in the first place. I think one exampl= e can be good to show how ``?'' is useful somehow in grep.

S= uppose 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 pa= ttern "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, bu= t 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 on= e
>> from "the practice of programming") and I am a little di= soriented 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 t= he 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 charac= ters
>> that desired, but it is not.
>> Saludos
>> --
>> Hugo
>>
>
>



--
Hugo


--0016364ece88ad2d52046b77b8d0--