Perl - 如何解码或替换 '从数据库到浏览器显示的单引号
我发现了很多与此相关的问题,但是没有任何问题可以帮助我解决它。由于我缺乏专业知识而出现问题。
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.
我不知所措。有人可以帮忙吗?
I have found lots of questions close to this but, nothing that helped me solve it. Prob due to my lack of expertise.
PHP has html_entity_decode
which could have helped but, Perl does not, I believe.
In my MySQL database I have ' "
following lengths in a description like: 12' 6"
I would like it to display as 12' 6".
I have tried:
$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.
I am at a loss. Can someone help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看看 HTML::Entities:
Have a look at HTML::Entities: