4
我在PHP利特尔表示:的Python:preg_replace函数功能模拟
$search = array("'<(script|noscript|style|noindex)[^>]*?>.*?</(script|noscript|style|noindex)>'si",
"'<\!--.*?-->'si",
"'<[\/\!]*?[^<>]*?>'si",
"'([\r\n])[\s]+'");
$replace = array ("",
"",
" ",
"\\1 ");
$text = preg_replace($search, $replace, $this->pageHtml);
我怎么没在蟒蛇跑的? re.sub
?
是,'re.sub'。你试过了吗? – bereal 2013-03-11 05:40:19
@bereal ok,我如何设置多个模式并替换为're.sub'? – 2013-03-11 05:49:12
它似乎没有特别的要求,但为什么不使用'|'如例如所述[这里](http://emilics.com/blog/article/multi_replace.html)? – bereal 2013-03-11 05:56:08