replace every occurrence of whitespaces in the previous result for '_', substitute the result for s. call the function re.sub with 3 arguments: raw string '(?u)[^-\w.]', an empty string and s, return the result.
return re . sub ( r'(?u)[^-\w.]' , '' , s )