import re


def get_eq_and_vals(filtered_sentence, variables, unclean_eq):
    """Parses and separates the equation part from the values in the string

    INPUTS
    =======
    filtered_sentence: a list of tokenized strings from the original equation
    variables: list of the user defined variables
    unclean_eq: essentially the version of the first input without stop the words

    RETURNS
    ========
    string: the equation part
    list: the variables and the values in the list

    EXAMPLES
    =========  
    >>> filtered_sentence = parse_sentence('x^2 + 2x when x is 1')
    >>> get_eq_and_vals(filtered_sentence, ['x', 'y'], 'x^2+2xx1')
    >>> ('x^2 + 2x', ['x', '1'])

    """
    regex_vars = ''
    for var in variables:
        regex_vars += var + '\d+\.*\d*'
        

    var_val_str = re.findall(regex_vars,unclean_eq)[0] 
    print('vvs', var_val_str)
    values = [i for i in re.findall('\d*\.*\d*', var_val_str) if i !='']
    print('vars_vals', values)
    equation = ''
    final_eq = ''.join(filtered_sentence)
    for i in final_eq.split(var_val_str):
        if i != '':
            equation = i
    
    return equation, values