Re: Cleaning strings with Regular Expressions

2005-09-08 Thread Gary Wilson Jr
sheffdog wrote: > Using regular expressions, the best I can do so far is using the re.sub > command but it still takes two lines. Can I do this in one line? Or > should I be approaching this differently? All I want to end up with is > the file name "ppbhat.tga". A regular expression to do what you

Re: Cleaning strings with Regular Expressions

2005-09-07 Thread sheffdog
Good Idea I'll try that! Thanks for your assistance. /\/\ -- http://mail.python.org/mailman/listinfo/python-list

Re: Cleaning strings with Regular Expressions

2005-09-06 Thread Fredrik Lundh
"sheffdog" <[EMAIL PROTECTED]> wrote: > Using basename works, but leaves the extra stuff at the end. > Which would have to be removed with another line of code > > I get this--> ppbhat.tga"; if you're trying to parse Maya files, maybe you should start by writing a simple Maya parser, and use

Re: Cleaning strings with Regular Expressions

2005-09-06 Thread sheffdog
Using basename works, but leaves the extra stuff at the end. Which would have to be removed with another line of code I get this--> ppbhat.tga"; Thanks, for the idea though. /\/\ason -- http://mail.python.org/mailman/listinfo/python-list

Re: Cleaning strings with Regular Expressions

2005-09-06 Thread Larry Bates
May not be what you are looking for, but this works: import os s='setAttr ".ftn" -type "string" ' \ '/assets/chars/boya/geo/textures/lod1/ppbhat.tga";' fname=os.path.basename(s.split()[-1]) BTW-It does depend on the file/path being the last item on the line. Larry Bates sheffdog wrote: > He

Re: Cleaning strings with Regular Expressions

2005-09-06 Thread Fredrik Lundh
"sheffdog" <[EMAIL PROTECTED]> wrote: > setAttr ".ftn" -type "string" /assets/chars/ >/boya/geo/textures/lod1/ppbhat.tga"; > Can I do this in one line? >>> os.path.basename("/assets/chars/.../lod1/ppbhat.tga") 'ppbhat.tga' -- http://mail.python.org/mailman/listinfo/python-list

Cleaning strings with Regular Expressions

2005-09-06 Thread sheffdog
Hello, I often find myself cleaning up strings like the following: setAttr ".ftn" -type "string" /assets/chars/ /boya/geo/textures/lod1/ppbhat.tga"; Using regular expressions, the best I can do so far is using the re.sub command but it still takes two lines. Can I do this in one line? O