Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

ignore cases

by Sara (Acolyte)
on Aug 01, 2002 at 19:26 UTC ( [id://186896]=perlquestion: print w/replies, xml ) Need Help??

Sara has asked for the wisdom of the Perl Monks concerning the following question:

Hello guys ,,, I am greping for litters by itself within a text somthing like :
W room hoom zoom room x zooom ddd w kaw llo sss
each line would contains only one line . the problem I am having is how to ignore upper and lower cases for example If i want to grep for w , I want to be apple to get both the W in first line and w in the third line not only the one in the third line b/c in match the case .. so basically how to you ignore the cases when grepping for a somthing .. thanks

Replies are listed 'Best First'.
Re: ignore cases
by aufrank (Pilgrim) on Aug 01, 2002 at 20:02 UTC
    sara--

    it seems like the majority of your posts deal with regex questions, and so I thought you might like to have some reference material to look at. things like the /i modifier will be old hat if you take the time to read these things over. without further ado:

    from the docs:
  • perlre
  • perlrequick
  • perlretut
  • from perlmonks tutorials:

  • String matching and Regular Expressions which continues on through several different useful nodes
  • pattern matching exercises are the exercises to go along with that regex tutorial
  • common regex gotchas is chromatic's addition to the regex tutorial, and I always find his writing very very helpful
  • finally, from the literature you might try:

  • chapters 7, 8, and 9 of merlyn's Learning Perl (3rd Edition) (AKA "the llama")
  • chapter 5 of Programming Perl (3rd edition) (AKA "the camel")
  • Mastering Regular Expressions (2nd edition). I haven't looked at this one myself, but I understand it's excellent, and the second edition has just recently come out

  • <update>
  • that DamnDirtyApe suggested that I add japhy's book. I'd never seen it, but plan to spend some time with it tonight. Thanks DDA!
    </update>

  • I often find that having a list of resources all in once place can be a big help, and your question just gave me an excuse to put one together on this topic. There's certainly far more out there in terms of resources, but even just reading the documentation provided with your distribution of perl or the tutorials offered on this site should help you to feel a lot more confident with your regexes.

    hope you look into these,
    --au
Re: ignore cases
by Cine (Friar) on Aug 01, 2002 at 19:29 UTC
    using /i modifier on your regex.
    eg. @result = grep {/w/i} @lines_to_search_in;

    T I M T O W T D I

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2024-04-26 06:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found