Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have a litle expression in 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);

How i did run this on python? re.sub?

share|improve this question
    
Yes, re.sub. Did you try it? –  bereal Mar 11 '13 at 5:40
    
@bereal ok, how did i set multiple patterns and replacements to re.sub? –  Roman Nazarkin Mar 11 '13 at 5:49
1  
It doesn't seem to have a special call for that, but why not using '|' as described e.g. here? –  bereal Mar 11 '13 at 5:56
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.