"GHUM" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Paul, > > > text = """ ... input source text ... "" > > from pyparsing import SkipTo,Literal,replaceWith > > ign1 = "$$" + SkipTo("$$") + "$$" > > ign2 = "$_$" + SkipTo("$_$") + "$_$" > > semi = Literal(";").setParseAction( replaceWith("; <***>") ) > > print (ign1 | ign2 | semi).transformString(text) > > Thank you very much! this really looks beautifull and short! How could > I forget about pyparsing? Old loves are often better then adventures > with RE. :)
Good to hear from you again, Harald! I didn't recognize your "From" address, but when I looked into the details, I recognized your name from when we talked about some very early incarnations of pyparsing. > > Two questions remain: > 1) I did not succeed in finding a documentation for pyparsing. Is there > something like a "full list of Classes and their methods" ? > Pyparsing ships with JPG and PNG files containing class diagrams, plus an htmldoc directory containing epydoc-generated help files. There are also about 20 example programs included (also accessible in the wiki). > 2) as of missing 1) :)): something like > "setParseAction(splithereandreturnalistofelementssplittedhere) ? > I briefly considered what this grammar might look like, and rejected it as much too complicated compared to .split("<***>"). You could also look into using scanString instead of transformString (scanString reports the location within the string of the matched text). Then when matching on a ";", use the match location to help slice up the string and append to a list. But again, this is so much more complicated than just .split("<***>"), I wouldn't bother other than as an exercise in learning scanString. Good luck! -- Paul -- http://mail.python.org/mailman/listinfo/python-list