import re


def get_similar_attributes(search_str, present_dict):
    """Search study metadata for attributes matching a given pattern.

    Parameters
    ----------
    search_str : str
        (Raw) string that is a valid regular expression to search for matching
        attribute names.
    present_dict : dict
        Dictionary returned by get_studies_by_present_attributes.

    Returns
    -------
    list
        List of metadata attributes matching the given pattern.
    """
    attr_re = re.compile(search_str, re.I)
    attrs = []
    for attr in present_dict:
        if attr_re.search(attr):
            attrs.append(attr)
    return attrs