Pyparsing - Dealing with a Blank Value

Paul McGuire ptmcg at
Fri Jan 26 05:07:16 CET 2007

On Jan 25, 7:13 pm, "Steve" <ste... at> wrote:
> Hi All,
> I've picked up thePyParsingmodule and am trying to figure out how to
> do a simple parsing of some HTML source code.  My specific problem is
> dealing with an <TD></TD> element that is blank.
> Any assistance would be greatly appreciated!
> Steve

Just define a default value to be returned for MultiItem if the
Optional expression is not found:

    MultiItem = Optional(OneOrMore(dataItem),default="")

Define default to be whatever string you choose.

-- Paul

More information about the Python-list mailing list