All pastes #32018 Raw Edit

david

public python v1 · immutable
#32018 ·published 2005-12-01 20:28 UTC
rendered paste body
def _in_tag(text, tag):    """Extracts text from inside a tag.    This function extracts the text from inside a given tag.    It's useful to get the text between <body></body> or    <pre></pre> when using the validators or the colorizer.    """    if text.count('<%s' % tag):        text = text.split('<%s' % tag, 1)[1]        if text.count('>'):            text = text.split('>', 1)[1]    if text.count('</%s' % tag):        text = text.split('</%s' % tag, 1)[0]    text = text.strip().replace('\r\n', '\n')    return text