Pyparsing - Dealing with a Blank Value

Paul McGuire ptmcg at austin.rr.com
Thu Jan 25 23:07:16 EST 2007


On Jan 25, 7:13 pm, "Steve" <ste... at cruzio.com> 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.
>
<snip>
>
> 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