def escapeRegExpString(string):
 toEscapeChars = ['\\', '(', ')', '.', '|', '^', '$', '*', '+', '?', '[', ']']
 escapedValue = ''
 for i in range(len(string)):
  if (string[i] in toEscapeChars):
   escapedValue += ('\\' + string[i])
  else:
   escapedValue += string[i]
 return escapedValue

def escapeRegExpString ( string ) : toEscapeChars = [ '\\' , '(' , ')' , '.' , '|' , '^' , '$' , '*' , '+' , '?' , '[' , ']' ] escapedValue = '' for i in range ( len ( string ) ) : if ( string [ i ] in toEscapeChars ) : escapedValue += ( '\\' + string [ i ] ) else : escapedValue += string [ i ] return escapedValue
escape the given string to include it as a regular expression .