Getting a unknown word out of a list with no spaces

2008-07-17 Thread Alexnb
Hello Lets say I have a string: --a href=/browse/brick--brick--/a-- The -- needs to be replaced with or where applicable. and I want the brick out of that string (the second brick that is). How can I get just the brick out of that string? -- View this message in context:

Re: Getting a unknown word out of a list with no spaces

2008-07-17 Thread Alexnb
Alexandr N Zamaraev wrote: s = '--a href=/browse/brick--brick--/a--' s '--a href=/browse/brick--brick--/a--' ''.join('%s' % l if i % 2 == 1 else l for i, l in enumerate(s.split('--'))) ' /browse/brick brick ' -- http://mail.python.org/mailman/listinfo/python-list I'm sorry, I

Re: Getting a unknown word out of a list with no spaces

2008-07-17 Thread Alexandr N Zamaraev
Alexnb wrote: s = '--a href=/browse/brick--brick--/a--' s '--a href=/browse/brick--brick--/a--' ''.join('%s' % l if i % 2 == 1 else l for i, l in enumerate(s.split('--'))) ' /browse/brick brick ' I'm sorry, I don't think I was being clear. I replaced the 's with -- so it would post online

Re: Getting a unknown word out of a list with no spaces

2008-07-17 Thread Alexnb
Alexandr N Zamaraev wrote: Alexnb wrote: s = '--a href=/browse/brick--brick--/a--' s '--a href=/browse/brick--brick--/a--' ''.join('%s' % l if i % 2 == 1 else l for i, l in enumerate(s.split('--'))) ' /browse/brick brick ' I'm sorry, I don't think I was being clear. I replaced the

Re: Getting a unknown word out of a list with no spaces

2008-07-17 Thread bearophileHUGS
On Jul 17, 9:50 am, Alexnb: how can I test to see if the first char of a string is ? I suggest you to try the interactive shell: hello[0] 'h' hello[0] == False hello[0] == h True hello.startswith(h) True Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list

Re: Getting a unknown word out of a list with no spaces

2008-07-17 Thread Alexnb
bearophileHUGS wrote: On Jul 17, 9:50 am, Alexnb: how can I test to see if the first char of a string is ? I suggest you to try the interactive shell: hello[0] 'h' hello[0] == False hello[0] == h True hello.startswith(h) True Bye, bearophile --

Re: Getting a unknown word out of a list with no spaces

2008-07-17 Thread Fredrik Lundh
Alexnb wrote: hello[0] 'h' hello[0] == False hello[0] == h True hello.startswith(h) True really? That's just like C. I thought that it would fail because of the way lists work. Thanks! what way? the first three will fail if the string is empty. [0] Traceback (most recent

Re: Getting a unknown word out of a list with no spaces

2008-07-17 Thread Calvin Spealman
BeautifulSoup. You need a good html parsing, not some one-shot code to handle one tiny unflexable pattern. On Thu, Jul 17, 2008 at 3:07 AM, Alexnb [EMAIL PROTECTED] wrote: Hello Lets say I have a string: --a href=/browse/brick--brick--/a-- The -- needs to be replaced with or where