# Buggy code
def visible_settings(self):
    result = [self.wants_metadata]
    if self.wants_metadata:
        for group in self.extraction_methods:
            if group.can_remove:
                result += [group.divider]
            result += [group.extraction_method]
            if group.extraction_method == X_MANUAL_EXTRACTION:
                result += [group.source]
                if group.source == XM_FILE_NAME:
                    result += [group.file_regexp]
                elif group.source == XM_FOLDER_NAME:
                    result += [group.folder_regexp]
                result += [group.filter_choice]
                if group.filter_choice == F_FILTERED_IMAGES:
                    result += [group.filter]
            elif group.extraction_method == X_IMPORTED_EXTRACTION:
                result += [group.csv_location, group.filter_choice]
                if group.filter_choice == F_FILTERED_IMAGES:
                    result += [group.filter]
                result += [group.csv_joiner, group.wants_case_insensitive]
            elif group.extraction_method == X_AUTOMATIC_EXTRACTION:
                result += [group.filter_choice]
                if group.filter_choice == F_FILTERED_IMAGES:
                    result += [group.filter]
                result += [group.update_metadata]
            if group.can_remove:
                result += [group.remover]
        result += [self.add_extraction_method_button]
        if len(self.get_dt_metadata_keys()) > 0:
            result += [self.dtc_divider, self.data_type_choice]
            if self.data_type_choice == DTC_CHOOSE:
                result.append(self.data_types)
        result += [self.table]
    return result


# Traceback (JavaException)
Traceback (most recent call last):
File "/Users/dlogan/github/CellProfiler/cellprofiler/gui/moduleview.py", line 1191, in on_kill_focus
self.set_selection(self.__module.module_num)
File "/Users/dlogan/github/CellProfiler/cellprofiler/gui/moduleview.py", line 400, in set_selection
self.__module.visible_settings())
File "/Users/dlogan/github/CellProfiler/cellprofiler/modules/metadata.py", line 641, in visible_settings
if len(self.get_dt_metadata_keys()) > 0:
File "/Users/dlogan/github/CellProfiler/cellprofiler/modules/metadata.py", line 954, in get_dt_metadata_keys
self.get_metadata_keys())
File "/Users/dlogan/github/CellProfiler/cellprofiler/modules/metadata.py", line 942, in get_metadata_keys
extractor = self.build_extractor(for_metadata_only=True)
File "/Users/dlogan/github/CellProfiler/cellprofiler/modules/metadata.py", line 772, in build_extractor
pattern, fltr)
File "/Users/dlogan/github/CellProfiler/cellprofiler/utilities/jutil.py", line 913, in call
result = fn(*nice_args)
File "/Users/dlogan/github/CellProfiler/cellprofiler/utilities/jutil.py", line 890, in fn
raise JavaException(x)
JavaException: Illegal repetition near index 8
POS([0-9]{)
^

# Fixed code
def visible_settings(self):
    result = [self.wants_metadata]
    if self.wants_metadata:
        for group in self.extraction_methods:
            if group.can_remove:
                result += [group.divider]
            result += [group.extraction_method]
            if group.extraction_method == X_MANUAL_EXTRACTION:
                result += [group.source]
                if group.source == XM_FILE_NAME:
                    result += [group.file_regexp]
                elif group.source == XM_FOLDER_NAME:
                    result += [group.folder_regexp]
                result += [group.filter_choice]
                if group.filter_choice == F_FILTERED_IMAGES:
                    result += [group.filter]
            elif group.extraction_method == X_IMPORTED_EXTRACTION:
                result += [group.csv_location, group.filter_choice]
                if group.filter_choice == F_FILTERED_IMAGES:
                    result += [group.filter]
                result += [group.csv_joiner, group.wants_case_insensitive]
            elif group.extraction_method == X_AUTOMATIC_EXTRACTION:
                result += [group.filter_choice]
                if group.filter_choice == F_FILTERED_IMAGES:
                    result += [group.filter]
                result += [group.update_metadata]
            if group.can_remove:
                result += [group.remover]
        result += [self.add_extraction_method_button]
        try:
            has_keys = len(self.get_dt_metadata_keys()) > 0
        except:
            has_keys = False
        if has_keys:
            result += [self.dtc_divider, self.data_type_choice]
            if self.data_type_choice == DTC_CHOOSE:
                result.append(self.data_types)
        result += [self.table]
    return result