splitting delimited strings

John Machin sjmachin at lexicon.net
Wed Jun 15 19:36:56 EDT 2005


Nicola Mingotti wrote:
> On Wed, 15 Jun 2005 23:03:55 +0000, Mark Harrison wrote:
>  
> 
>>What's the most efficient way to process this?  Failing all
>>else I will split the string into characters and use a FSM,
>>but it seems that's not very pythonesqe.
> 
> 
> like this ?

No, not like that. The OP said that an embedded @ was doubled.

> 
> 
>>>>s = "@hello at world@@foo at bar"
>>>>s.split("@")
> 
> ['', 'hello', 'world', '', 'foo', 'bar']
> 
>>>>s2 = "hello at world@@foo at bar"
>>>>s2
> 
> 'hello at world@@foo at bar'
> 
>>>>s2.split("@")
> 
> ['hello', 'world', '', 'foo', 'bar']
> 
> 
> bye



More information about the Python-list mailing list