[PerlChina] 大家好,小弟弟我碰到个问题,请大家帮忙给看看呀

haidong jia haidongj at gmail.com
Tue Jul 11 00:32:52 PDT 2006


功能:把文本中含有<books:xxxxx>的部分全部替换为空
遇到问题:当字符串为<books:xxxxx>开头并且以它结尾的时候把整个字符串都给替换了,现在求一正确的方法,多谢.
代码如下
sub strip_books {
  my $str = shift;
  my %allowed = allbooks;

  my $j = Jcode->new(\$str, 'utf-8');

  $j->s("(<books:(.+)>)", exists $allowed{$2} ? '' : $1);

  return $j->utf8;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/china-pm/attachments/20060711/de1b852a/attachment.html 


More information about the China-pm mailing list