in reply to Re: how to select which words have Y and W
in thread how to select which words have Y and W

i tried like this but it doesn't show any result
my@colors=('red', 'cyan', 'yellow', 'blue' ); my @yw_colors = grep {/yw/} @colors;

Replies are listed 'Best First'.
Re^3: how to select which words have Y and W
by jethro (Monsignor) on Dec 26, 2013 at 10:53 UTC

    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,$/
    A reply falls below the community's threshold of quality. You may see it by logging in.