def _match_pattern(self):
        buf = []
        while self.c != EOF and self.c != self.delimiter:
            if self.c == '\\':
                buf.append(self.c)
                self.consume()
                if self.c == self.delimiter:
                    # Overwrite the \ we've just stored.
                    buf[-1] = self.delimiter
                    self.consume()
                if self.c in '\\':
                    buf.append(self.c) # BUGFIXED: still need to escape \ in python regex!
                    self.consume()

                if self.c == EOF:
                    break
            else:
                buf.append(self.c)
                self.consume()

        return ''.join(buf)
dataset/ETHPy150Open SublimeText/VintageEx/vex/parsers/s_cmd.py/SubstituteLexer._match_pattern/original