Split text file into words

Duncan Booth duncan.booth at invalid.invalid
Tue Mar 8 09:00:27 EST 2005


qwweeeit wrote:

> The standard split() can use only one delimiter. To split a text file
> into words  you need multiple delimiters like blank, punctuation, math
> signs (+-*/), parenteses and so on.
> 
> I didn't succeeded in using re.split()...
> 

Would you care to elaborate on how you tried to use re.split and failed? We 
aren't mind readers here. An example of your non-working code along with 
the expected result and the actual result would be useful.

This is the first example given in the documentation for re.split:

   >>> re.split('\W+', 'Words, words, words.')
   ['Words', 'words', 'words', '']

Does it do what you want? If not what do you want?



More information about the Python-list mailing list