Skip to content

Instantly share code, notes, and snippets.

@SoltauFintel
Created September 25, 2023 13:33
Show Gist options
  • Save SoltauFintel/390c281e72cad76a944ee269f9dfe585 to your computer and use it in GitHub Desktop.
Save SoltauFintel/390c281e72cad76a944ee269f9dfe585 to your computer and use it in GitHub Desktop.
non case-sensitive replace
/**
* non case-sensitive replace()
* @param text to be changed text
* @param alt this text is to be replaced
* @param neu replace by this text
* @return text with replaced alt
*/
public static String ireplace(final String text, final String alt, final String neu) {
return text.replaceAll("(?i)" + alt.replace("{", "\\{").replace("}", "\\}"), neu);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment