def parse(self):
        """Apply search template."""

        self.verbose = bool(self.re_verbose)
        self.version = self.re_version if self.re_version else _regex.DEFAULT_VERSION
        self.global_flag_swap = {
            "version": self.re_version != 0,
            "verbose": False
        }
        self.temp_global_flag_swap = {
            "version": False,
            "verbose": False
        }

        new_pattern = []
        text = self.process_quotes(self.search.decode('latin-1') if self.is_bytes else self.search)

        i = _util.StringIter(text)
        iter(i)

        retry = True
        while retry:
            retry = False
            try:
                new_pattern = self.main_group(i)
            except GlobalRetryException:
                # Prevent a loop of retry over and over for a pattern like ((?V0)(?V1))
                # or on V0 (?-x:(?x))
                if self.temp_global_flag_swap['version']:
                    if self.global_flag_swap['version']:
                        raise LoopException('Global version flag recursion.')
                    else:
                        self.global_flag_swap["version"] = True
                if self.temp_global_flag_swap['verbose']:
                    if self.global_flag_swap['verbose']:
                        raise LoopException('Global verbose flag recursion.')
                    else:
                        self.global_flag_swap['verbose'] = True
                self.temp_global_flag_swap = {
                    "version": False,
                    "verbose": False
                }
                i.rewind(i.index)
                retry = True

        return "".join(new_pattern).encode('latin-1') if self.is_bytes else "".join(new_pattern)