import re


def strip_empty_lines(lines):
    """Strip empty lines from start and end of array of lines."""
    empty_line = re.compile('\s*$')
    while len(lines) > 0 and empty_line.match(lines[ 0]): del lines[ 0]
    while len(lines) > 0 and empty_line.match(lines[-1]): del lines[-1]
    return lines