[Linux OT] Regular expresion question
Brad De Vries
devriesbj
Tue Oct 5 15:24:54 PDT 2004
Kevin's right, the ".9" matches September but the reason I added the
"." was because the last line of the data had "h207904" and I got the
impression you wanted that line/file as well.
Regarding the "top-post" stuff, wasn't there a lengthy, heated
discussion regarding this? IIRC, there was a general consensus to use
"bottom-post." I can read/write on either side so it doesn't matter
much to me.
Brad.
On Tue, 5 Oct 2004 06:45:56 -0700, Kevin O'Gorman <kogorman at gmail.com> wrote:
> The ".9" specifies September. The '.' matches any single character, while the
> 9 matches literally. Since the only candidates are going to be 09,
> this does the
> trick. To match just November, you'd have to use "11", because ".1" would match
> both January (01) and November(11), while "1." would match 10, 11 and 12.
>
> Number ranges are a bit hard in regular expressions because REs are not
> designed for any numeric interpretation at all. They are purely text matches.
> Character ranges like [0-5] can help, but they are not the same thing.
>
> ++ kevin
>
>
>
> On Tue, 05 Oct 2004 05:37:16 -0500, Jean Sagi <jeansagi at uniweb.net.co> wrote:
> >
> > You example works for the case I give. Thanks.
> >
> > I didn't understand ".9" in the patterns you gave; what they are used for?
> >
> > The pattern works with them and without them, I mean the next statement
> > works the way I want:
> >
> > [chucho at oolnta hist]$ ls | grep -e "^h1[0-9].9" -e "^h2[0-5].9"
> > h100904
> > h120904
> > h130904
> > h180904
> > h200904
> > h240904
> > h250904
> >
> > [chucho at oolnta hist]$ ls | grep -e "^h1[0-9]" -e "^h2[0-5]"
> > h100904
> > h120904
> > h130904
> > h180904
> > h200904
> > h240904
> > h250904
> >
> > Finally I wonder if there is a more generic way of handling ranges with
> > regular expresions, or maybe I'm trying to use the way they are not
> > meant to.
> >
> > Chucho!
> >
> >
> >
> > Brad De Vries wrote:
> > > Jean, you could try sed using the following syntax:
> > > $ sed -n -e "/^h1[0-9].9/p" -e "/^h2[0-5].9/p"
> > >
> > >
>
> --
> Go back to the top: I almost always top-post
> Kevin O'Gorman, PhD
More information about the Linux-users
mailing list