in reply to Re: Re: Grep Pattern Match
in thread Grep Pattern Match

The former looks right to me, though the easiest way is to check is to try it:)

Why did you think that you might need the extra '.' in the latter?


Examine what is said, not who speaks.

Replies are listed 'Best First'.
Re: Re: Re: Re: Grep Pattern Match
by LostS (Friar) on Dec 27, 2002 at 15:45 UTC
    Hummm ok a quiz I guess... put it there cause I saw you put it before the * which made me thing hey myabe I need to seperate the sections with a . first section being the nc then a variable but due to it is s $year I am kind of worried cause you use $ for end of statement... but also figure having that . in front of the $ made it think hey maybe treat $year as a variable... am I close??

    -----------------------
    Billy S.
    Slinar Hardtail - Hand of Dane
    Datal Ephialtes - Guildless
    RallosZek.Net Admin/WebMaster

    perl -e '$cat = "cat"; if ($cat =~ /\143\x61\x74/) { print "Its a cat! +\n"; } else { print "Thats a dog\n"; } print "\n";'

      Ok. In a regex '.' means match any char. (*)

      '*' means zero or more of the preceeding char. (**)

      So '.*' just means any number of any characters. (*)

      If you know for that you only want to match digits, then you would be better using \d* or if you know that there must be at least 2 then \d{2,}.

      There's much to much to lay it all out here and it's already written many places perlre would be a good starting point. It will only take you 20 minutes to read it, and you won't take it all in at one go probably, but once you seen it, you'll probably remember were to look next time.

      (*)(except \n except in special cases which we can ignore for now, but the internet laywers and perlitists may be watching:)

      (**) more correctly, "preceding pattern"


      Examine what is said, not who speaks.

        I suck at regex... Hell I even admit it... maybe I should find a book like "Regex for Dummies" or "Idiots guide to Regex" That entire structure confuses me sometimes... But thank you for showing me this stuff... It is greatly appricated.

        -----------------------
        Billy S.
        Slinar Hardtail - Hand of Dane
        Datal Ephialtes - Guildless
        RallosZek.Net Admin/WebMaster

        perl -e '$cat = "cat"; if ($cat =~ /\143\x61\x74/) { print "Its a cat! +\n"; } else { print "Thats a dog\n"; } print "\n";'