Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making character class with modifier symbols in Perl 6

Tags:

raku

I'd like to make a user-defined character class of "vowels", which will match any literal English vowel letter (a, e, i, o, u) as well as any of these letters with any possible diacritics: ắ ḗ ú̱ å ų̄ ẹ́ etc.

This is what I've tried to do, but it doesn't work:

> my $vowel = / <[aeiou]> <:Sk>* /
/ <[aeiou]> <:Sk>* /
> "áei" ~~ m:g/ <$vowel> /
(「e」 「i」)
like image 796
Eugene Barsky Avatar asked Oct 29 '18 20:10

Eugene Barsky


1 Answers

You could try use ignoremark:

The :ignoremark or :m adverb instructs the regex engine to only compare base characters, and ignore additional marks such as combining accents.

For your example:

my $vowel = /:m<[aeiou]>/;
.say for "áeikj" ~~ m:g/ <$vowel> /;

Output:

「á」
「e」
「i」
like image 67
Håkon Hægland Avatar answered Nov 02 '22 03:11

Håkon Hægland