in reply to Re: regex: help for improvement
in thread regex: help for improvement
To treat names with accented letter (say utf8) using your function, I tried this
my ($str) = @_; $str =~ tr/-/ /; #$str =~ tr/a-zA-Z/ /cs; my $new; while ( $str =~ m/\G([\p{isUpper}|\p{isLower}|\s]+)/g ) { $new.=$1; } $str = $new; $str =~ s/(?<=\p{isLower})(?=\p{isUpper})/ /g; $str =~ s/(?:(?<=\s)|(?<=^))(\p{isLower})/\u$1/g; $str =~ s/\s+$//r
but it's not working since any character that is not a letter or a space break the loop and the rest is lost. How can I adapt tr/a-zA-Z/ /cs for unicode character ?
Thanks
F.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: regex: help for improvement
by choroba (Cardinal) on Dec 14, 2018 at 14:35 UTC | |
by frazap (Monk) on Dec 14, 2018 at 15:25 UTC | |
|
Re^3: regex: help for improvement
by AnomalousMonk (Archbishop) on Dec 14, 2018 at 19:21 UTC | |
|
Re^3: regex: help for improvement
by Laurent_R (Canon) on Dec 14, 2018 at 18:16 UTC |