'Asynchronously read until we have matched the given regex.
The result includes the data that matches the regex and anything
that came before it.  If a callback is given, it will be run
with the data as an argument; if not, this method returns a
`.Future`.
If ``max_bytes`` is not None, the connection will be closed
if more than ``max_bytes`` bytes have been read and the regex is
not satisfied.
.. versionchanged:: 4.0
Added the ``max_bytes`` argument.  The ``callback`` argument is
now optional and a `.Future` will be returned if it is omitted.'

def read_until_regex(self, regex, callback=None, max_bytes=None):

    future = self._set_read_callback(callback)
    self._read_regex = re.compile(regex)
    self._read_max_bytes = max_bytes
    try:
        self._try_inline_read()
    except UnsatisfiableReadError as e:
        gen_log.info(('Unsatisfiable    read,    closing    connection:    %s' % e))
        self.close(exc_info=True)
        return future
    except:
        if (future is not None):
            future.add_done_callback((lambda f: f.exception()))
        raise
    return future
