def remaining_args(oldArgs, newArgList):
 pattern = ('\\s+'.join((re.escape(a) for a in newArgList)) + '\\s*$')
 matchObj = re.search(pattern, oldArgs)
 return oldArgs[matchObj.start():]

def remaining_args ( oldArgs , newArgList ) : pattern = ( '\\s+' . join ( ( re . escape ( a ) for a in newArgList ) ) + '\\s*$' ) matchObj = re . search ( pattern , oldArgs ) return oldArgs [ matchObj . start ( ) : ]
preserves the spacing originally in the argument after the removal of options .