(expr, asString=True)
return matchExpr
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 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 asString argument is passed as False, then the return value is a 
       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 originalTextFor contains expressions with defined
       results names, you must set asString to False if you want to preserve those
       results name values.
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 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 asString argument is passed as False, then the return value is a 
       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 originalTextFor contains expressions with defined
       results names, you must set asString to False if you want to preserve those
       results name values.
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 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 asString argument is passed as False then the return value is a 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 originalTextFor contains expressions with defined results names you must set asString to False if you want to preserve those results name values .
def originalTextFor(expr, asString=True):
    """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 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 asString argument is passed as False, then the return value is a 
       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 originalTextFor contains expressions with defined
       results names, you must set asString to False if you want to preserve those
       results name values."""
    locMarker = Empty().setParseAction(lambda s,loc,t: loc)
    matchExpr = locMarker("_original_start") + expr + locMarker("_original_end")
    if asString:
        extractText = lambda s,l,t: s[t._original_start:t._original_end]
    else:
        def extractText(s,l,t):
            del t[:]
            t.insert(0, s[t._original_start:t._original_end])
            del t["_original_start"]
            del t["_original_end"]
    matchExpr.setParseAction(extractText)
    return matchExpr
def originalTextFor ( expr , asString = True ) : locMarker = Empty ( ) . setParseAction ( lambda s , loc , t : loc ) matchExpr = locMarker ( "_original_start" ) + expr + locMarker ( "_original_end" ) if asString : extractText = lambda s , l , t : s [ t . _original_start : t . _original_end ] else : def extractText ( s , l , t ) : del t [ : ] t . insert ( 0 , s [ t . _original_start : t . _original_end ] ) del t [ "_original_start" ] del t [ "_original_end" ] matchExpr . setParseAction ( extractText ) return matchExpr