def strip_regex_metachars(pattern):
 start = 0
 till = len(pattern)
 if pattern.startswith('^'):
  start = 1
 if pattern.endswith('$'):
  till -= 1
 return pattern[start:till]

def strip_regex_metachars ( pattern ) : start = 0 till = len ( pattern ) if pattern . startswith ( '^' ) : start = 1 if pattern . endswith ( '$' ) : till -= 1 return pattern [ start : till ]
strip ^ and $ from pattern begining and end .