Showing posts with label string. Show all posts
Showing posts with label string. Show all posts

All permutations of string

public static void permutation(String str) { 
    permutation("", str); 
}

private static void permutation(String prefix, String str) {
    int n = str.length();
    if (n == 0) System.out.println(prefix);
    else {
        for (int i = 0; i < n; i++)
            permutation(prefix + str.charAt(i), str.substring(0, i) + str.substring(i+1, n));
    }
}

How to check if String contains Sub String with Java Script or Jquery

Case Sensitive
if (originalString.indexOf("substring") >= 0)

Case In-Sensitive
if (originalString.toLowerCase().indexOf("substring") >= 0)
Or,
if (/substring/i.test(originalString))