@staticmethod
    def filter_by_selector(selector, search_regions):
        regions = []
        filter_pattern = re.compile("(\\[(?P<FilterAny>>)?(?P<Filter>[\\w-]+)=(?P<Value>[^\\]]*)\\])")
        filter_match = filter_pattern.search(selector)

        filter_selector = None
        if filter_match:
            selector = selector[:-len(filter_match.group(0))]
            filter_any = filter_match.group("FilterAny") and filter_match.group("FilterAny") is not ""
            filter_selector = filter_match.group("Filter")
            filter_value = filter_match.group("Value")

        find_name = selector.startswith("@")
        if find_name:
            selector = selector[1:]
        find_any = selector.startswith(">")
        if find_any:
            selector = selector[1:]
        find_child = selector.endswith(">")
        if find_child:
            selector = selector[:-1]

        for region in search_regions:
            key = "parent"
            if find_name:
                key = "name"

            is_child = region["parent"] in selector + ">"
            child_filtered = not filter_selector or GrammarParser.filter_region(region, selector, filter_any, filter_selector, filter_value, search_regions)

            if find_any:
                if region[key].endswith(selector) and not is_child:
                    if not child_filtered:
                        continue
                    if find_child:
                        regions += GrammarParser.filter_inside_region([region["begin"], region["end"]], search_regions)
                    else:
                        regions.append(region)
            else:
                if key is "name" and region[key] is selector and not is_child:
                    if not child_filtered:
                        continue
                    if find_child:
                        regions += GrammarParser.filter_inside_region([region["begin"], region["end"]], search_regions)
                    else:
                        regions.append(region)
                elif region[key].startswith(selector) and not is_child:
                    if not child_filtered:
                        continue
                    if find_child:
                        regions += GrammarParser.filter_inside_region([region["begin"], region["end"]], search_regions)
                    else:
                        regions.append(region)
        return regions
dataset/ETHPy150Open spywhere/Javatar/parser/GrammarParser.py/GrammarParser.filter_by_selector/swapped operands of `in`