我发现了很多与此相近的问题,但没有任何帮助我解决的问题。可能是因为我缺乏专业知识。
PHP 有 html_entity_decode
,我相信这可能有帮助,但 Perl 没有。
在我的 MySQL 数据库中,我有 ' "
如下描述中的长度:12' 6"
我希望它显示为 12' 6"。
我试过:
$string =~ s/:[']:/'/g;
$string =~ s/:["]:/"/g;
$string =~ s/'/'/g;
$string =~ s/"/"/g;
$string =~ s/\'/'/g;
$string =~ s/\"/"/g;
$string =~ s/\'/\'/g;
$string =~ s/\"/\"/g;
perl -pi -e 's:':':g' $_; #crashes.
perl -pi -e 's:":":g' $string #also crashes.
system -pi -e 's:':':g' $_; #crashes.
system -pi -e 's:":":g' $string #also crashes.
我很茫然。有人可以帮忙吗?
最佳答案
看看HTML::Entities :
use warnings;
use strict;
use HTML::Entities;
my $str = '12' 6"';
print decode_entities($str);
关于mysql - Perl - 如何将数据库中的 ' 解码或替换为单引号以供浏览器显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4770190/