RE Despair - help required

2005-08-25 Thread Yoav
I am trying the following: re.search(r'\\[^\\]+(?=(?$))', c:\ret_files) and I get a return of NoneType, and I have no idea why. I know that I missing something here, but I really can't figure out why (I bet it's something obvious). I also tried this RE on KODOS and it works fine there, so I

Re: RE Despair - help required

2005-08-25 Thread Robert Kern
Yoav wrote: I am trying the following: re.search(r'\\[^\\]+(?=(?$))', c:\ret_files) and I get a return of NoneType, and I have no idea why. I know that I missing something here, but I really can't figure out why (I bet it's something obvious). I also tried this RE on KODOS and it works

Re: RE Despair - help required

2005-08-25 Thread Sybren Stuvel
Yoav enlightened us with: I am trying the following: re.search(r'\\[^\\]+(?=(?$))', c:\ret_files) and I get a return of NoneType, and I have no idea why. Because you don't match a carriage return \r. I know that I missing something here, but I really can't figure out why (I bet it's

Re: RE Despair - help required

2005-08-25 Thread Fredrik Lundh
Yoav wrote: I am trying the following: re.search(r'\\[^\\]+(?=(?$))', c:\ret_files) and I get a return of NoneType, and I have no idea why. I know that I missing something here, but I really can't figure out why instead of struggling with weird REs, why not use Python's standard filename

Re: RE Despair - help required

2005-08-25 Thread Yoav
Thanks guys. Issue solved. I am also going to give Microsoft a call about it. Any other issues you want me to raise while I am talking to them? Cheers. Robert Kern wrote: Yoav wrote: I am trying the following: re.search(r'\\[^\\]+(?=(?$))', c:\ret_files) and I get a return of NoneType,

Re: RE Despair - help required

2005-08-25 Thread Yoav
Don't think it will do much good. I need to get them from a file and extract the last folder in the path. For example: if I get c:\dos\util I want to extract the string \util Fredrik Lundh wrote: Yoav wrote: I am trying the following: re.search(r'\\[^\\]+(?=(?$))', c:\ret_files) and I

Re: RE Despair - help required

2005-08-25 Thread rafi
Yoav wrote: Don't think it will do much good. I need to get them from a file and extract the last folder in the path. For example: if I get c:\dos\util I want to extract the string \util like frederik says (I use '/' as I am using Unix): import os os.path.split ('c:/foo/bar')

Re: RE Despair - help required

2005-08-25 Thread Reinhold Birkenfeld
Yoav wrote: Don't think it will do much good. I need to get them from a file and extract the last folder in the path. For example: if I get c:\dos\util I want to extract the string \util Then os.path.basename should be for you. Reinhold --

RE: RE Despair - help required

2005-08-25 Thread Marc Boeren
Hi, Don't think it will do much good. I need to get them from a file and extract the last folder in the path. For example: if I get c:\dos\util I want to extract the string \util Still, os.path is your friend: import os filepath = r'C:\dos\util' base, last = os.path.split(filepath)

Re: RE Despair - help required

2005-08-25 Thread Robert Kern
Yoav wrote: Don't think it will do much good. I need to get them from a file and extract the last folder in the path. For example: if I get c:\dos\util I want to extract the string \util You mean like this: import os os.path.sep + os.path.split(rc:\dos\util)[-1] -- Robert Kern [EMAIL

Re: RE Despair - help required

2005-08-25 Thread Sion Arrowsmith
In article [EMAIL PROTECTED], Yoav [EMAIL PROTECTED] wrote: Fredrik Lundh wrote: Yoav wrote: I am trying the following: re.search(r'\\[^\\]+(?=(?$))', c:\ret_files) instead of struggling with weird REs, why not use Python's standard filename manipulation library instead?

Re: RE Despair - help required

2005-08-25 Thread Yoav
Thank you all guys. It seems like the simpler the solution, the more I am happy about it. Sorry, for the simple question, I am quite new to this lang. Cheers. Robert Kern wrote: Yoav wrote: Don't think it will do much good. I need to get them from a file and extract the last folder in the