Excellent summary Justin!
  Big thanks and it was a good read with the morning cup just now.  Looking 
into regular expressions in python using the example Justin provided and see if 
I can build from there.  Some links here below:

http://docs.python.org/2/library/re.html
http://docs.python.org/2/library/re.html#examples
http://docs.python.org/2/howto/regex.html#regex-howto
http://docs.python.org/2/library/re.html#regular-expression-syntax
http://stackoverflow.com/questions/6323296/python-remove-anything-that-is-not-a-letter-or-number


  My issue however is apparent in this example:

def clean( name , seperator=' ' ):
    
    name = name.rsplit( '.' )
    
    name1='%s.%s' % ( re.sub( r'[^\w_.]+' , seperator , ''.join( name[ :-1 ] )) 
, name[-1] )
    name2='%s.%s' % ( re.sub( r'[^\w.]+' , seperator , ''.join( name[ :-1 ] )) 
, name[-1] )
    name3='%s.%s' % ( re.sub( r'[^\W_.]' , seperator , ''.join( name[ :-1 ] )) 
, name[-1] )
    name4='%s.%s' % ( re.sub( r'[^\_]+' , seperator , ''.join( name[ :-1 ] )) , 
name[-1] )
        
    return name1 , name2 , name3 , name4

  
  This returns from the filename 'a silly ! looking   @windows  -    file.ext' 
respectively:
name1 = a silly looking __ windows file.ext
name2 = a silly looking __ windows file.ext
name3 =         !         __  @         -        .ext
name4 =  __ .ext

  It all works fine when swapping anything to an underscore, but replacing the 
underscore with either a dash or a space always leaves the underscore within 
the name.  name4 catches the characters I want to swap out but swaps out the 
opposite.  I think I'm getting confused between the LOCALE and UNICODE flags...?

-- 
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