import re


def is_same_gws(path1, path2):
    """
    Check that two paths both start with the same group workspace name.

    It's assumed that both paths are both in either the old-style or both
    in the new-style format.

    :param str path1: The first path
    :param str path2: The second path
    :returns: True if both paths are in the same group workspace
    """
    if path1.startswith('/group_workspaces'):
        gws_pattern = r'^/group_workspaces/jasmin2/primavera\d'
    elif path1.startswith('/gws'):
        gws_pattern = r'^/gws/nopw/j04/primavera\d'
    else:
        return False
    gws1 = re.match(gws_pattern, path1)
    gws2 = re.match(gws_pattern, path2)

    if not gws1 or not gws2:
        return False

    return True if gws1.group(0) == gws2.group(0) else False