Twitter Updates

Sunday, 17 January 2010

Java case insensitive regular search and replace

Java's Search and replace function on strings is:
new_string = old_string.replaceFirst(regularExpresionFind, textReplace);


To make this non-case sensitive / case insenitive:
new_string = old_string.replaceFirst("(?i)" + regularExpresionFind, textReplace);

No comments: