package seedu.taskitty.commons.util;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Arrays;
import java.util.List;

/**
 * Helper functions for handling strings.
 */
public class StringUtil {
    public static boolean containsIgnoreCase(String source, String query) {
        String[] split = source.toLowerCase().split("\\s+");
        List<String> strings = Arrays.asList(split);
        return strings.stream().filter(s -> s.contains(query.toLowerCase())).count() > 0;
    }

    /**
     * Returns a detailed message of the t, including the stack trace.
     */
    public static String getDetails(Throwable t){
        assert t != null;
        StringWriter sw = new StringWriter();
        t.printStackTrace(new PrintWriter(sw));
        return t.getMessage() + "\n" + sw.toString();
    }

    /**
     * Returns true if s represents an unsigned integer e.g. 1, 2, 3, ... <br>
     *   Will return false for null, empty string, "-1", "0", "+1", and " 2 " (untrimmed) "3 0" (contains whitespace).
     * @param s Should be trimmed.
     */
    public static boolean isUnsignedInteger(String s){
        return s != null && s.matches("^0*[1-9]\\d*$");
    }
    
    /**
     * Returns true if s represents an unsigned integer e.g. 0, 1, 2, 3, ... <br>
     *   Will return false if the String is not a valid integer
     * @param s Should be trimmed.
     */
    public static boolean isInteger(String s){
        return s != null && s.matches("^[0-9]\\d*$");
    }
    
    public static int findNextOccuranceOfInteger(String s, int indexFrom) {
        for (int i = indexFrom; i < s.length(); i++) {
            if (isUnsignedInteger(s.substring(i, i + 1))) {
                return i;
            }
        }
        return s.length();
    }
    
}

@@ -1497,290 +1497,6 @@
   %7D%0A
-    %0A    public static int findNextOccuranceOfInteger(String s, int indexFrom) %7B%0A        for (int i = indexFrom; i %3C s.length(); i++) %7B%0A            if (isUnsignedInteger(s.substring(i, i + 1))) %7B%0A                return i;%0A            %7D%0A        %7D%0A        return s.length();%0A    %7D%0A    %0A
 %7D%0A

Remove unused codes