def format_type_string_regex(node_class):
    """Format the type string regex to match nodes that are a sub class of the given node class.

    For example, for the CalculationNode class, the type string is given by::

        node.process.calculation.CalculationNode.

    To obtain the regex string that can be used to match sub classes, one has to strip the last period and
    the class name::

        nodes.process.calculation.

    Any node with a type string that starts with this sub string is a sub class of the `CalculationNode` class.

    :param node_class: the node class for which to get the sub class regex string
    :return: a string that can be used as regex to match nodes that are a sub class of the given node class
    """
    # 'nodes.process.calculation.CalculationNode.'
    type_string = node_class._plugin_type_string  # pylint: disable=protected-access

    # ['nodes', 'process', 'calculation']
    type_parts = type_string.split('.')[:-2]

    # 'nodes.process.calculation.'
    type_string_regex = f"{'.'.join(type_parts)}."

    return type_string_regex