I want to check one long string contain multiple string.
I am trying to use below command.
String[] words = {"GAGGAG", "AGGAC"};
Pattern pattern = Pattern.compile("GAGGAG|AGGAC");
if(pattern.matcher("GAGGAGGTC").find()){
System.out.println("find");
}else{
System.out.println("Not find");
}
Results supposed to be Not Find because "GAGGAGGTC" contain "GAGGAG" but does not contain "AGGAC"
How can I give option from "or" to "And"
And There is one more option.
String[] words = {"GAGGAG", "AGGAC"};
Pattern pattern = Pattern.compile("GAGGAG|AGGAC");
if(pattern.matcher("GAGGAGGAC").find()){
System.out.println("find");
}else{
System.out.println("Not find");
}
This is also should show "Not find". Because There is not allowing overlap part. "GAGGAG" and "AGGAC" is overlapping "AG" part from "GAGGAGGAAC"