def find_regex(self, name_regex: str) -> Dict[str, Optional[ConnectedConsulLockInformation]]:
        """
        Finds the locks with key names that match the given regex.
        :param name_regex: key name regex
        :return: keys that match
        """
        # Gets prefix directory (must not include regex!)
        escaped_name_regex = re.escape(name_regex)
        directory_prefix = os.path.commonprefix(
            (name_regex.replace(KEY_DIRECTORY_SEPARATOR, re.escape(KEY_DIRECTORY_SEPARATOR)), escaped_name_regex)) \
            .replace("\\", "")

        data = self.consul_client.kv.get(directory_prefix, recurse=True)[1]
        if data is None:
            return dict()
        key_indexed_data = {key_data["Key"]: key_data for key_data in data}

        name_pattern = re.compile(name_regex)
        matches = [value for key, value in key_indexed_data.items() if name_pattern.fullmatch(key) is not None]
        matched_return: Dict[str, Optional[ConsulLockInformation]] = dict()
        for match in matches:
            try:
                decoded_match = json.loads(match["Value"], cls=ConsulLockInformationJSONDecoder)
                matched_return[decoded_match.key] = decoded_match
            except JSONDecodeError:
                matched_return[match["Key"]] = None
        return matched_return