def originalTextFor(expr, asString=True):
locMarker = Empty().setParseAction(lambda s,loc,t: loc)<EOL>endlocMarker = locMarker.copy()<EOL>endlocMarker.callPreparse = False<EOL>matchExpr = locMarker("<STR_LIT>") + expr + endlocMarker("<STR_LIT>")<EOL>if asString:<EOL><INDENT>extractText = lambda s,l,t: s[t._original_start:t._original_end]<EOL><DEDENT>else:<EOL><INDENT>def extractText(s,l,t):<EOL><INDENT>del t[:]<EOL>t.insert(<NUM_LIT:0>, s[t._original_start:t._original_end])<EOL>del t["<STR_LIT>"]<EOL>del t["<STR_LIT>"]<EOL><DEDENT><DEDENT>matchExpr.setParseAction(extractText)<EOL>return matchExpr<EOL>
Helper to return the original, untokenized text for a given expression.  Useful to
       restore the parsed fields of an HTML start tag into the raw tag text itself, or to
       revert separate tokens with intervening whitespace back to the original matching
       input text. Simpler to use than the parse action C{L{keepOriginalText}}, and does not
       require the inspect module to chase up the call stack.  By default, returns a 
       string containing the original parsed text.  

       If the optional C{asString} argument is passed as C{False}, then the return value is a 
       C{L{ParseResults}} containing any results names that were originally matched, and a 
       single token containing the original matched text from the input string.  So if 
       the expression passed to C{L{originalTextFor}} contains expressions with defined
       results names, you must set C{asString} to C{False} if you want to preserve those
       results name values.