By default regexp matching is case sensitive. To make it case insensitive use the CASE_INSENSITIVE flag in your regex. It can be embedded in the regex string using (?i).
String s = "aBcXYZABCdefAbc"; String replaced = s.replaceAll("(?i)abc", "123");
2 Responses to “How do I replace all occurences of a string regardless of case?”
Leave a Reply
You must be logged in to post a comment.