Re: Spliting a string on non alpha characters

2006-09-23 Thread bearophileHUGS
stdazi: The RE-based solutions look good. Here is a pair of alternative solutions: s1 = 'foo bar- blah/hm.lala' r1 = ['foo', 'bar', 'blah', 'hm', 'lala'] s2 = 'foobbbar.. xyz' r2 = ['foo', 'bbbar', 'xyz'] table = "".join((c if c.isalpha() else " " for c) in map(chr, range(256))) #table = ""

Re: Spliting a string on non alpha characters

2006-09-23 Thread Mark Peters
> I'm relatively new to python but I already noticed that many lines of > python code can be simplified to a oneliner by some clever coder. As > the topics says, I'm trying to split lines like this : > > 'foo bar- blah/hm.lala' -> [foo, bar, blah, hm, lala] > > 'foobbbar.. xyz' -> [foo, bbbar,

Re: Spliting a string on non alpha characters

2006-09-23 Thread Tim Chase
> I'm relatively new to python but I already noticed that many lines of > python code can be simplified to a oneliner by some clever coder. As > the topics says, I'm trying to split lines like this : > > 'foo bar- blah/hm.lala' -> [foo, bar, blah, hm, lala] > > 'foobbbar.. xyz' -> [foo, bbbar

Spliting a string on non alpha characters

2006-09-23 Thread stdazi
Hello! I'm relatively new to python but I already noticed that many lines of python code can be simplified to a oneliner by some clever coder. As the topics says, I'm trying to split lines like this : 'foo bar- blah/hm.lala' -> [foo, bar, blah, hm, lala] 'foobbbar.. xyz' -> [foo, bbbar, xyz]