gpt4 book ai didi

mysql - Perl - 如何将数据库中的 ' 解码或替换为单引号以供浏览器显示

转载 作者:行者123 更新时间:2023-11-29 04:13:12 25 4
gpt4 key购买 nike

我发现了很多与此相近的问题,但没有任何帮助我解决的问题。可能是因为我缺乏专业知识。

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com