Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Re: Re: Re: Grep Pattern Match

by LostS (Friar)
on Dec 27, 2002 at 15:45 UTC ( [id://222555]=note: print w/replies, xml ) Need Help??


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

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";'

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Grep Pattern Match
by BrowserUk (Patriarch) on Dec 27, 2002 at 16:00 UTC

    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";'

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://222555]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2024-04-20 03:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found