Making character class with modifier symbols in Perl 6

  • A+
Category:Languages

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」) 

 


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」 

Comment

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: