我有一个在PHP中的小表达式:
$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
函数呢?
re.sub
。你试过了吗? - berealre.sub
中? - Roman Nazarkin