Demo Site

Saturday, November 27, 2010

multi line search and replace in eclipse (and across multiple files)

This is surprisingly more difficult that it should be. Search and replace across multiple files is covered very well here:

http://www.avajava.com/tutorials/lessons/how-do-i-do-a-find-and-replace-in-multiple-files-in-eclipse.html?page=2


but searching for things that span more than one line, wasn't covered almost anywhere, so here goes.

1. multi line search can only be accomplished by regex in eclipse (I'm using helios), so searching for something like -

 replace me
 replace me 2

would require an expressions like 'word1[\s\S]*word2' or 'word1[\s\S]*?word2' for a non-greedy expression.


to get the text back in, you'll need to also put it in one line, so a site like this can come in handy:


http://kangax.github.com/html-minifier/

No comments:

Labels

Labels

Labels