This topic has been archived. It cannot be replied.
-
工作学习 / IT技术讨论 / 一个perl简单问题一个字符串的内容是 'abc'
我想去掉头尾的‘符号,除 s/'//g 方法外,有没有简单方法或perl function?
谢谢!
-bluelotus(时光漫步);
2003-9-11
{110}
(#1365276@0)
-
试一试这个下面的方法可能你的要稍快一点,因为只查首尾字符:
方法1:
$string = "'abc'";
$string =~ s/^'|'$//g; #remove the first and the last quote.
方法2:
$string = "'abc'";
$string =~ s/^'(.+)'$/$1/; # $1 is the string without quote.
-hunterz(Hunter);
2003-9-12
{246}
(#1366384@0)
-
thanks
-bluelotus(时光漫步);
2003-9-12
(#1366465@0)