[Tutor] RE: re
Kirk Bailey
idiot1 at netzero.net
Fri Oct 3 21:44:21 EDT 2003
Regarding re (regular expressions):
%#$^^&*$^@$@!
I am fustrated. I want a function to return a list or a string which is a
WikiWord split into words, with the split occuring at the Capitalized word.
So if I feed it the word ThisIsAWikiWord, it can give me back:
'This Is A Wiki Word'
*OR*
['This','Is','A','Wiki','Word']
Well, I got THIS far...
>>> def wordsplit(word):
return re.split('[A-Z]+',word)
>>> wordsplit(word)
['', 'ary', 'ad', 'ittle', 'amb']
>>> word
'MaryHadALittleLamb'
>>>
Please advise. 'Text Processing in Python' is good, but the RE chapter is not as
transparent as I would hope. Clue eagerly saught.
--
--
end
Cheers!
Kirk D Bailey
+ think +
http://www.howlermonkey.net +-----+ http://www.tinylist.org
http://www.listville.net | BOX | http://www.sacredelectron.org
Thou art free"-ERIS +-----+ 'Got a light?'-Prometheus
+ kniht +
Fnord.
More information about the Tutor
mailing list