On 07/10/2011 01:38, Marc wrote:
> On Oct 6, 2011, at 4:44 PM, Jim Gibson wrote:
> 
>> You should go back to your original character class of [bcdfghjklmnpqrstvwxz]
> 
>       Making this change fixed the "Rex'S" problem, but it didn't capitalize 
> LKJ because the rest of the code had capitalized the acronym as Lkj.  So I 
> changed that line to:
> $string =~ 
> s~\b([aeiouyAEIOUY]{3,4}|[bcdfghjklmnpqrstvwxzBCDFGHJKLMNPQRSTVWXZ]{3,4})\b~uc$1~eg;
> 
> and now it works, even though it's a mile long. ;)  Thanks for helping me to 
> think about it differently.
> 
> Marc

Just add the /i modifer (as you had originally) and there is no need to
list both the upper and lower case alphabetics.

Also, it is far better to use the standard delimiters for s/// and m//
unless you are dealing with string with a lot of slashes in them

Capturing parenthese should be avoided unless the are needed

And there is no need for an executable substituion string when \U will
do the upper casing for you:

  $string =~ s/\b(?:[aeiouy]{3,4}|[bcdfghjklmnpqrstvwxz]{3,4})\b/\U$1/gi;

HTH,

Rob

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to