String[] (String source, String substr) { if (substr != null && !substr.isEmpty()) { int index = Math.max(source.indexOf(substr), 0); String prefix = (index > 0) ? source.substring(0, index) : null; index += substr.length(); String suffix = (index < source.length() - 1) ? source.substring(index) : null; return new String[]{prefix, substr, suffix}; } return new String[]{source, null, null}; }