in reply to regex: help for improvement
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,
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: regex: help for improvement
by frazap (Monk) on Dec 14, 2018 at 14:11 UTC | |
by choroba (Cardinal) on Dec 14, 2018 at 14:35 UTC | |
by frazap (Monk) on Dec 14, 2018 at 15:25 UTC | |
by AnomalousMonk (Archbishop) on Dec 14, 2018 at 19:21 UTC | |
by Laurent_R (Canon) on Dec 14, 2018 at 18:16 UTC |