import retestString = "Hello world"formatString = "%-35s: %s" # string for formatting the outputexpression = "Hello"compiledExpression = re.compile( expression ) print formatString % ( "The expression", expression )print formatString % ( "The compiled expression",compiledExpression )print formatString % ( "Non-compiled search",re.search( expression, testString ) )print formatString % ( "Compiled search",compiledExpression.search( testString ) )print formatString % ( "search SRE_Match contains",re.search( expression, testString ).group() )print formatString % ( "compiled search SRE_Match contains",compiledExpression.search( testString ).group() )
Name (required)
email (will not be published) (required)
Website