Monday, April 25, 2011

Regular Expression Search/Replace with IntelliJ

I recently got tasked with reviewing some HTML documentation for my company's product. In the documentation, many instances of the abbreviation "ID" were used. Except, they were being used inconsistently. Sometimes it was "ID", sometimes it was "Id", and sometimes it was "id". Luckily, IntelliJ supports find/replace with regular expressions.

find: id([ .,;!])
replace with: ID$1

The capture group (in the parenthesis) preserves the punctuation if there is any with the "$1" part of the replace.

No comments:

Post a Comment