public static void main(String[] args) { String temp=" CLASS_path : /aaabb/"; System.out.println(temp.replaceAll("(?i)\sclass(_?)path\s:","")); System.out.println(temp.replaceAll("classpatH","")); }
public static void main(String[] args) { String path=" Class__Path : /aaabb/"; String patten="\s*class(_?)path\s*:\s*"; if(Pattern.compile(patten+".*", Pattern.CASE_INSENSITIVE).matcher(path).matches()){ System.out.println(path.replaceAll("(?i)"+patten,"")); } }