#  Substitute anything that isn't a number or letter with a separator character

sep = "_"
original = 'a silly ! looking __  @windows  -    file.ext'

name, ext = os.path.splitext(s)
cleaned = re.sub(r'[^a-zA-Z0-9]+', sep, name)
path = ''.join([cleaned, ext])
# a_silly_looking_windows_file.ext



On May 18, 2013, at 8:47 PM, Ævar Guðmundsson wrote:

> 
> Meant to say from the filename 'a silly ! looking __  @windows  -    
> file.ext' of  course :)
> 
> On Saturday, May 18, 2013 9:44:46 AM UTC+1, Ævar Guðmundsson wrote:
>>  This returns from the filename 'a silly ! looking   @windows  -    
>> file.ext' respectively:
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To post to this group, send email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
> 
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to