#NEWLINE# def _escape_for_regex( text ) : #NEWLINE# #INDENT# 'Escape ``text`` to allow literal matching using egrep' #NEWLINE# regex = re . escape ( text ) #NEWLINE# regex = regex . replace ( '\\\\' , '\\\\\\' ) #NEWLINE# regex = regex . replace ( '\\$' , '\\\\\\$' ) #NEWLINE# regex = regex . replace ( "\\'" , "'" ) #NEWLINE# return text