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: Re: Re: Re: Regexp for alphabetical order match within the string
by sauoq (Abbot) on Oct 30, 2003 at 21:00 UTC |