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

Re: how to select which words have Y and W

by LanX (Bishop)
on Dec 26, 2013 at 10:30 UTC ( #1068409=note: print w/replies, xml ) Need Help??


in reply to how to select which words have Y and W

Try this

 @selection = grep { /REGEX/ } @array

and plz give us feedback with code you tried.

see also grep and perlre

Cheers Rolf

( addicted to the Perl Programming Language)

Replies are listed 'Best First'.
Re^2: how to select which words have Y and W
by rammohan (Acolyte) on Dec 26, 2013 at 10:44 UTC
    i tried like this but it doesn't show any result
    my@colors=('red', 'cyan', 'yellow', 'blue' ); my @yw_colors = grep {/yw/} @colors;

      UPDATE: Add a print statement. And the regex should be /x|y/, i.e. you want to find an x or an y, not x followed by y. Another possible regex that would work would use a character class: /[xy]/

        i tried but it doesn't work,slightly i change my code then it works that is
        my @yw_colors = grep {/yw/} @colors; ' print @yw_colors,$/
        here we used [] or |.what is the functionality of those symbols please let me know because am a beginner

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1068409]
help
Chatterbox?
[LanX]: ehm ... nope ... a PM discussion not a meditation
[LanX]: I spend too much time in this alsmhouse ... cheers o/
[Discipulus]: what articular point of view.. i intrepreted the only question mark as rethoric.. but i'm strange

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2017-11-23 20:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (337 votes). Check out past polls.

    Notices?