A helper function which can be used similarly to fscanf(fid,'%f',num) to extract num arguments from the regex iterator

def r_get_numbers(matchgroup, num):
    """A helper function which can be used similarly to fscanf(fid,'%f',num) to extract num arguments from the regex iterator"""
    res = []
    for i in range(num):
        res.append(float(matchgroup.next().group()))
    return np.array(res)