splitting strings with python

Kent Johnson kent37 at tds.net
Thu Jun 9 13:28:23 EDT 2005


sbucking at gmail.com wrote:
> im trying to split a string with this form (the string is from a
> japanese dictionary file with mulitple definitions in english for each
> japanese word)
> 
> 
> str1 [str2] / (def1, ...) (1) def2 / def3 / .... (2) def4/ def5 ... /
> 
> 
> the varibles i need are str*, def*.

Could you post a few examples of real data and what you want to extract from it? The above raises a few questions:
- are str* and def* single words or can they include whitespace, comma, slash, paren...
- not clear what replaces the ... (or if they are literal)

This might be a good job for PyParsing.

Kent
> 
> sometimes the (1) and (2) are not included - they are included only if
> the word has two different meanings
> 
> 
> "..." means that there are sometimes more then two definitions per
> meaning.
> 
> 
> im trying to use the re.split() function but with no luck.
> 
> Is this possible with python, or am i dreamin!?
> 
> All the best,
> 
> .
> 



More information about the Python-list mailing list