def setResultsName( self, name, listAllMatches=False ):
newself = self.copy()<EOL>if name.endswith("<STR_LIT:*>"):<EOL><INDENT>name = name[:-<NUM_LIT:1>]<EOL>listAllMatches=True<EOL><DEDENT>newself.resultsName = name<EOL>newself.modalResults = not listAllMatches<EOL>return newself<EOL>
Define name for referencing matching tokens as a nested attribute
of the returned parse results.
NOTE: this returns a *copy* of the original :class:`ParserElement` object;
this is so that the client can define a basic element, such as an
integer, and reference it in multiple places with different names.

You can also set results names using the abbreviated syntax,
``expr("name")`` in place of ``expr.setResultsName("name")``
- see :class:`__call__`.

Example::

    date_str = (integer.setResultsName("year") + '/'
                + integer.setResultsName("month") + '/'
                + integer.setResultsName("day"))

    # equivalent form:
    date_str = integer("year") + '/' + integer("month") + '/' + integer("day")