<?xml version="1.0" encoding="windows-1252"?>
<node id="416690" title="Re: Regular expressions and accents" created="2004-12-21 23:31:23" updated="2005-06-27 20:21:44">
<type id="11">
note</type>
<author id="44715">
graff</author>
<data>
<field name="doctext">
Larry Wall recently posted this nifty little script on the perl-unicode mail list -- here it is, pretty much verbatim (I added the "S" on the shebang line, to make STDIN/STDOUT/STDERR be utf8):
&lt;code&gt;
#!/usr/bin/perl -CS

$pat = shift;
if (ord $pat &gt; 256) {
    $pat = sprintf("%04x", ord $pat);
}
elsif (ord $pat &gt; 128) {        # arg in sneaky UTF-8
    $pat = sprintf("%04x", unpack("U0U",$pat));
}
 
@names = split /^/, do 'unicore/Name.pl';
for (@names) {
    if (/$pat/io) {
        $hex = hex($_);
        print chr($hex),"\t",$_;
    }
}
&lt;/code&gt;
The idea is to output a list of unicode code points (if any) that match any given expression you put into &lt;code&gt; $ARGV[0] &lt;/code&gt; -- here's a relevant command-line usage example (Larry had this script in a file named "uni"):
&lt;code&gt;

uni "latin (?:small|capital) letter A with"

&lt;/code&gt;
(update: if you try this, you'll want to be running in a terminal window that handles utf8 characters!)
&lt;P&gt;
So, all you need for what you want is the part that assigns the output of "unicode/Name.pl" to an array -- this gives you the unicode character database -- and grep through the array to get the set of vowels you want.  Then, put the first token (first character in each array element is the utf8 character itself) into a character-class expression.
Something like:
&lt;code&gt;
my @names = split/^/, do 'unicore/Name.pl';

#...

my @vowelsets;
for my $v ( qw/A E I O U/ ) {
    push( @vowelsets, 
          join( '', map { chr hex( substr $_, 0, 4 ) }
                grep /LATIN (?:SMALL|CAPITAL) LETTER $v/, @names ));
}

# now you can use each element of @vowelsets as a character class
# (similiarly for consonants...)

&lt;/code&gt;
(updated this snippet: changed the map block from a regex to substr; updated a second time to use "chr hex()" in the map block -- each element of @names begins with a four-digit hex code-point value, which needs to be converted to a character.)
&lt;P&gt;
Still a bit cumbersome, I suppose, but quite manageable and not that bulky.</field>
<field name="root_node">
416513</field>
<field name="parent_node">
416513</field>
</data>
</node>
