DEV Community

Discussion on: Daily Challenge #80 - Longest Vowel Change

Collapse
 
choroba profile image
E. Choroba • Edited

Perl solution, tests included.

#!/usr/bin/perl
use warnings;
use strict;

sub longest_vowel_substring {
    my ($string) = @_;
    my $max_length = 0;
    $max_length < length $1 and $max_length = length $1
        while $string =~ /([aeiou]+)/g;
    $max_length
}

use Test::More tests => 2;
is longest_vowel_substring('codewarriors'), 2;
is longest_vowel_substring('xaaeexaeiooxxaxax'), 5;