def convert_namespaces_str(<EOL>bel_str: str,<EOL>api_url: str = None,<EOL>namespace_targets: Mapping[str, List[str]] = None,<EOL>canonicalize: bool = False,<EOL>decanonicalize: bool = False,<EOL>) -> str:
<EOL>matches = re.findall(r'<STR_LIT>', bel_str)<EOL>for nsarg in matches:<EOL><INDENT>if "<STR_LIT>" in nsarg:  <EOL><INDENT>continue<EOL><DEDENT>updated_nsarg = convert_nsarg(<EOL>nsarg,<EOL>api_url=api_url,<EOL>namespace_targets=namespace_targets,<EOL>canonicalize=canonicalize,<EOL>decanonicalize=decanonicalize,<EOL>)<EOL>if updated_nsarg != nsarg:<EOL><INDENT>bel_str = bel_str.replace(nsarg, updated_nsarg)<EOL><DEDENT><DEDENT>return bel_str<EOL>
Convert namespace in string

    Uses a regex expression to extract all NSArgs and replace them with the
    updated NSArg from the BEL.bio API terms endpoint.

    Args:
        bel_str (str): bel statement string or partial string (e.g. subject or object)
        api_url (str): BEL.bio api url to use, e.g. https://api.bel.bio/v1
        namespace_targets (Mapping[str, List[str]]): formatted as in configuration file example
        canonicalize (bool): use canonicalize endpoint/namespace targets
        decanonicalize (bool): use decanonicalize endpoint/namespace targets

    Results:
        str: bel statement with namespaces converted