Perl:
$string =~ s/[áàa?]/a/gi; #This line always prepends an "a"
$string =~ s/[éèê?]/e/gi;
$string =~ s/[úù?ü]/u/gi;
This regular expression should convert "été" into "ete". Instead, it is converting it to "aetae". In other words, it prepends an "a" to every matched element. Even "à" is converted to "aa".
If I change the first line to this
$string =~ s/(á|à|a|?)/a/gi;
it works, but... Now it prepends an e
to every matched element (like "eetee").
Even though I found a suitable solution, why does it behave that way?
Edit 1:
I added "use utf8;", but it did not change the behavior (although it broke my output in JavaScript/AJAX).
Edit2:
The Stream originates from an Ajax Request, performed by jQuery. The site it originates from is set to UTF-8.
I am using Perl v5.10 (perl -v
returns "This is perl, v5.10.0 built for i586-linux-thread-multi").
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…