Getting a unknown word out of a list with no spaces

Alexnb alexnbryan at gmail.com
Thu Jul 17 03:50:59 EDT 2008




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 <'s with -- so
>> it
>> would post online w/o actually making a link. I just need to know how to
>> get
>> the "brick" out.
> 1) if string really '--a href="/browse/brick"--brick--/a--'
>  >>> s.split('--', 3)[2]
> brick
> 2) if string ' /browse/brick brick '
>  >>> s.split('>', 1)[1].split('<')[0]
> brick
> --
> http://mail.python.org/mailman/listinfo/python-list
> 
> 

Excellent! it works. But I have one more question. How can I test to see if
the first character of a string is what I want, for example, how can I test
to see if  the first char of a string is "<"?

-- 
View this message in context: http://www.nabble.com/Getting-a-unknown-word-out-of-a-list-with-no-spaces-tp18502758p18503367.html
Sent from the Python - python-list mailing list archive at Nabble.com.




More information about the Python-list mailing list