<?xml version="1.0" encoding="windows-1252"?>
<node id="944294" title="Re: regex to find vowels in anyorder" created="2011-12-19 15:20:29" updated="2011-12-19 15:20:29">
<type id="11">
note</type>
<author id="258724">
Not_a_Number</author>
<data>
<field name="doctext">
&lt;blockquote&gt;I'm trying to find a regex that will...&lt;/blockquote&gt;
&lt;p&gt;You don't need no steenkin' regex:&lt;/p&gt;
&lt;c&gt;open my $fh, '&lt;', 'whatever'; # or whatever

my %hash = ( a =&gt; 0, e =&gt; 1, i =&gt; 2, o =&gt; 3, u =&gt; 4 );

while ( &lt;$fh&gt; ) {
  chomp;
  
  my $copy = $_;
  my @array;

  while ( my $char = lc chop $copy ) {
    no warnings 'uninitialized';
    $array[ $hash{ $char } ] = 1;
  }

  say if ( grep $_, @array ) == 5;
}&lt;/c&gt;
&lt;p&gt;Pretty fast, too, you'll find...&lt;/p&gt;

Update: Hmm, if you take out the line &lt;c&gt;no warnings 'uninitialized';&lt;/c&gt; (and therefore remove &lt;c&gt;use warnings&lt;/c&gt; or whatever from the start of the code), it seems to run nearly 20% faster still...&lt;/p&gt;
&lt;p&gt;Comments welcome.&lt;/p&gt;

&lt;p&gt;Update 2: Oops, just realised that my code doesn't work! Change the contents of the inner &lt;c&gt;while&lt;/c&gt; loop to:&lt;/p&gt;
&lt;c&gt;$array[ $hash{ $char } ] = 1 if defined $hash{ $char };&lt;/c&gt;
&lt;p&gt;Which is what I had originally, before playing with &lt;c&gt;no warnings 'uninitialized';&lt;/c&gt;. And then I didn't test properly.&lt;/p&gt;
&lt;p&gt;Mea culpa.&lt;/p&gt;</field>
<field name="root_node">
944253</field>
<field name="parent_node">
944253</field>
</data>
</node>
