def get_valid_filename(s):
 s = s.strip().replace(' ', '_')
 return re.sub('[^-A-Za-z0-9_.]', '', s)

def get_valid_filename ( s ) : s = s . strip ( ) . replace ( ' ' , '_' ) return re . sub ( '[^-A-Za-z0-9_.]' , '' , s )
returns the given string converted to a string that can be used for a clean filename .