Perl6 What is the best way to match any of the words?

I am trying to find an easy way to match any of the words. I am using a for loop, but is there an easier way?

my @a=<abcde f>; my $x="a1234567"; say $x ~~ m/ @a.any /; 

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

+5
source share
1 answer
 my @a = <abcde f>; my $x = "a1234567"; say $x ~~ /@a/; 

/@a/ matches /| @a/ /| @a/ , which is the longest rotation. For alternation you can use /|| @a/ /|| @a/ .

+4
source

Source: https://habr.com/ru/post/1262113/


All Articles