private static int subStringForAcharAtAnIndex(String s, String set, List<String> subStrings, char ipChar, int index) {
        index = s.indexOf(ipChar, index + 1);
        int x = 1;
        int l = index - x;
        int r = index + x + 1;
        while (l >= 0 || r <= s.length()) {
            l = l < 0 ? 0 : l;
            r = r > s.length() ? s.length() : r;
            String subStr = s.substring(l, r);
            // System.out.println("ip = " + s + ", Sol = " + subStr);
            char[] charArray = set.toCharArray();
            boolean containsAll = true;
            for (char c : charArray) {
                if (!StringUtils.contains(subStr, c)) {
                    // this substring does not contain all the chars, increase the size of substring
                    containsAll = false;
                    break;
                }
            }
            if (containsAll) {
                subStr = ltrim(subStr, charArray);
                subStr = rtrim(subStr, charArray);
                subStrings.add(subStr);
                break;
            }
            x += 1;
            l = index - x;
            r = index + x + 1;
        }
        return index;
    }