删除微标志unicode字符

时间:2014-07-04 09:09:08

标签: regex perl unicode

我正在尝试使用perl正则表达式从字符串中去除微(μ)unicode字符。拿字符串

$string = "This is a micro μ and some more μμμ";

使用强力方法删除所有“更专业”的unicode字符可以完成这项工作,即

$string =~ s/[\x80-\xFF]+//g;

但以下单挑微角色对我来说不起作用

$string =~ s/\xB5+//g;

非常确定00B5是微型标志的unicode。我出错的任何想法?

1 个答案:

答案 0 :(得分:3)

这可能不是微型标志,请查看类似的希腊小写字母mu,tobyink has suggested in his comment

#!/usr/bin/perl
use strict;
use warnings;
use utf8;
my $string = "This is a micro μ and some more μμμ";
$string =~ s/\x{03BC}//g;
print $string;

输出:This is a micro and some more

Demo

参考文献: