I tried to solve this with only regexes:
#!/usr/bin/perl use warnings; use strict; use Test::More; while ( my $t = <DATA> ) { chomp $t; is new_translate($t), translate($t); } done_testing(); sub translate { # the OP's code here } sub new_translate { my ($str) = @_; $str =~ tr/-/ /; $str =~ tr/a-zA-Z/ /cs; $str =~ s/(?<=\p{isLower})(?=\p{isUpper})/ /g; $str =~ s/(?:(?<=\s)|(?<=^))(\p{isLower})/\u$1/g; $str =~ s/\s+$//r }
($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
In reply to Re: regex: help for improvement
by choroba
in thread regex: help for improvement
by frazap
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |