I am solving a problem where I need to match different case insensitive permutations of a given word in the target string.
For example :
word to match : cAda
target string : AbrAcadAbRa
Here, 2 possible permutations that can be found in the target string S are Acad and cadA.
I have written something like this :
String pattern = "" ;
for(char ch : word.toCharArray()){
pattern = pattern + "(?=[\\s\\S]*(" + ch + "))" ;
}
pattern = "^" + pattern + "*$";
Pattern r = Pattern.compile(pattern, Pattern.CASE_INSENSITIVE);
It does not work.