def _convert_java_pattern_to_python(pattern):
 s = list(pattern)
 i = 0
 while (i < (len(s) - 1)):
  c = s[i]
  if ((c == '$') and (s[(i + 1)] in '0123456789')):
   s[i] = '\\'
  elif ((c == '\\') and (s[(i + 1)] == '$')):
   s[i] = ''
   i += 1
  i += 1
 return pattern[:0].join(s)

def _convert_java_pattern_to_python ( pattern ) : s = list ( pattern ) i = 0 while ( i < ( len ( s ) - 1 ) ) : c = s [ i ] if ( ( c == '$' ) and ( s [ ( i + 1 ) ] in '0123456789' ) ) : s [ i ] = '\\' elif ( ( c == '\\' ) and ( s [ ( i + 1 ) ] == '$' ) ) : s [ i ] = '' i += 1 i += 1 return pattern [ : 0 ] . join ( s )
convert a replacement pattern from the java-style $5 to the python-style 5 .