Re: split string into multi-character "letters"

2010-08-25 Thread Terry Reedy
On 08/25/10 14:46, Jed wrote: I would like to split the string 'churro' into a list containing: 'ch','u','rr','o' Dirt simple, straightforward, easily generalized solution: def sp_split(s): n,i,ret = len(s), 0, [] while i < n: s2 = s[i:i+2] if s2 in ('ch', 'll', 'r

Re: split string into multi-character "letters"

2010-08-25 Thread Alexander Kapps
Jed wrote: Hi, I'm seeking help with a fairly simple string processing task. I've simplified what I'm actually doing into a hypothetical equivalent. Suppose I want to take a word in Spanish, and divide it into individual letters. The problem is that there are a few 2-character combinations that

Re: split string into multi-character "letters"

2010-08-25 Thread Thomas Jollans
On Wednesday 25 August 2010, it occurred to Jed to exclaim: > Hi, I'm seeking help with a fairly simple string processing task. > I've simplified what I'm actually doing into a hypothetical > equivalent. > Suppose I want to take a word in Spanish, and divide it into > individual letters. The probl

Re: split string into multi-character "letters"

2010-08-25 Thread Tim Chase
On 08/25/10 14:46, Jed wrote: Hi, I'm seeking help with a fairly simple string processing task. I've simplified what I'm actually doing into a hypothetical equivalent. Suppose I want to take a word in Spanish, and divide it into individual letters. The problem is that there are a few 2-character

Re: split string into multi-character "letters"

2010-08-25 Thread MRAB
On 25/08/2010 20:46, Jed wrote: Hi, I'm seeking help with a fairly simple string processing task. I've simplified what I'm actually doing into a hypothetical equivalent. Suppose I want to take a word in Spanish, and divide it into individual letters. The problem is that there are a few 2-charact

Re: split string into multi-character "letters"

2010-08-25 Thread Jussi Piitulainen
Jed writes: > alphabet = ['a','b','c','ch','d','u','r','rr','o'] #this would > include the whole alphabet but I shortened it here > theword = 'churro' > > I would like to split the string 'churro' into a list containing: > > 'ch','u','rr','o' All non-overlapping matches, each as long as can be,

Re: split string into multi-character "letters"

2010-08-25 Thread Vlastimil Brom
2010/8/25 Jed : > Hi, I'm seeking help with a fairly simple string processing task. > I've simplified what I'm actually doing into a hypothetical > equivalent. > Suppose I want to take a word in Spanish, and divide it into > individual letters.  The problem is that there are a few 2-character > com

split string into multi-character "letters"

2010-08-25 Thread Jed
Hi, I'm seeking help with a fairly simple string processing task. I've simplified what I'm actually doing into a hypothetical equivalent. Suppose I want to take a word in Spanish, and divide it into individual letters. The problem is that there are a few 2-character combinations that are considere