void () { String filtersText = myInstanceFiltersField.getText(); ArrayList<InstanceFilter> idxs = new ArrayList<>(); int startNumber = -1; for (int i = 0; i <= filtersText.length(); i++) { if (i < filtersText.length() && Character.isDigit(filtersText.charAt(i))) { if (startNumber == -1) { startNumber = i; } } else { if (startNumber >= 0) { idxs.add(InstanceFilter.create(filtersText.substring(startNumber, i))); startNumber = -1; } } } myInstanceFilters = StreamEx.of(myInstanceFilters).remove(InstanceFilter::isEnabled).prepend(idxs).toArray(InstanceFilter[]::new); }