我在PHP中有一个litle表达式:
$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);
我是怎么在python上运行这个的?re.sub
?
作为@bereal commented使用正则表达式模块^{} 。
这里有一个简单的例子
Python:
为了好玩,在PHP上也有:
相关问题 更多 >
编程相关推荐