Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

perl6 What is the best way to match any of a group of words?

Tags:

I am trying to find a simple way to match any of a group of words. I have been using a for loop, but is there a simpler way?

my @a=<a b c d e f>;
my $x="a1234567";
say $x ~~ m/ @a.any /;

It returns False. Is there a way to make it work? Thanks.

like image 922
lisprogtor Avatar asked Dec 31 '16 06:12

lisprogtor


1 Answers

my @a = <a b c d e f>;
my $x = "a1234567";
say $x ~~ /@a/;

/@a/ is the same as /| @a/ which is longest alternation. For alternation you can use /|| @a/.

like image 92
CIAvash Avatar answered Sep 21 '22 10:09

CIAvash