in reply to Re: Re: Regexp for alphabetical order match within the string
in thread Regexp for alphabetical order match within the string

++, but the original post obviously allows non-alphabetical chars in the string, and their orders are not considered. A small improvement to meet the original requirement:

$str = "aBcD12ef7812g"; print is_alphabetical($str); sub is_alphabetical { (my $str = lc(shift)) =~ s/([^a-z])//g; my @c = split //, $str; $c[$_] ge $c[$_ - 1] or return 0 for 1 .. $#c; return 1; }

Replies are listed 'Best First'.
Re:x4 Regexp for alphabetical order match within the string
by Roy Johnson (Monsignor) on Oct 30, 2003 at 21:32 UTC
    Re: s/([^a-z])//g:
    Please, tr/a-z//dc is feeling unloved.
Re: Re: Re: Re: Regexp for alphabetical order match within the string
by sauoq (Abbot) on Oct 30, 2003 at 21:00 UTC
    but the original post obviously allows non-alphabetical chars in the string, and their orders are not considered.

    Actually, the regular expression in the original post did not match any non-alphabetic or even uppercase characters. (Okay, as the original wasn't anchored, I guess it did permit such characters in the string, but then it didn't deal with more than a single group of characters. And beyond that it matched the empty string.)

    I intentionally neglected those questions as I didn't feel they were really specified.

    -sauoq
    "My two cents aren't worth a dime.";