Oct
01
|
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");
Array ( ) 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.
December 10th, 2011 at 6:14 pm
Brilliant code! Helped a lot! Thank you!
February 11th, 2013 at 10:49 pm
Nice very helpful