[Solved] Extracting a substring based on second occurence using Java – substringBetween() function [closed]


You can use regex and Pattern matching to extract it, e.g.:

String s = "If this is good and if that is bad";
Pattern pattern = Pattern.compile("if(.*?)is");
Matcher m = pattern.matcher(s);
if(m.find()){
    System.out.println(m.group(1).trim());
}

3

solved Extracting a substring based on second occurence using Java – substringBetween() function [closed]