import re


def clean_regex_string(s: str) -> str:
    """Converts regex string pattern for a path into OpenAPI format.

    Example::

        >>s = '^toy\\/^(?P<toyId>[a-zA-Z0-9-_]+)\\/details'
        >>clean_regex_string(s)
        'toy/{toyId}/details'

    """
    s = s.replace("^", "").replace("\\", "")
    regex_pattern = r"\(\?P<([a-zA-Z0-9-_]*)>.*?\)"
    return re.sub(regex_pattern, r"{\1}", s).replace("?", "").replace("$", "")