views:

51

answers:

3

I would like to search all files via eclipse which contain the following 2 lines

    @Length(max = L_255)
    private String description;

and replace it with 
    @Length(max = L_255, message="{validator.description.len}")
    private String description;
+2  A: 

Select the folder that contains all your files and press Ctrl-H.

Bart van Heukelom
no, CTRL+H doesn't take 2 lines, that is my problem
Samuel
Do the lines separately? Or try a multiline regular expression.
Bart van Heukelom
I can't do it separately since it might affect other fields. I wasn't able to figure out the multiline expression which will correctly identify the above 2 lines, hence the question.
Samuel
A: 

Try PilotEdit Lite, it is FREE. It is a good tool to replace multi-line text. http://www.pilotedit.com

Dracoder
We would prefer to stick with the Eclipse environment for this issue, if it doesn't work I will have no choice other than to try the pilot edit tool. Thanks for the info
Samuel
+3  A: 

Search are multi-line by default in Eclipse when you are using regex:

(\@Length\(max = L_255)\)([\r\n\s]+private)

I would like to add "private String description;"

(\@Length\(max = L_255)\)([\r\n\s]+private\s+?String\s+description\s*?;)

replaced by:

\1, message="{validator.description.len}")\2

It works perfectly in a File Search triggered by a CTRL-H.

alt text

VonC
I would like to add "private String description;" also as part of my search since the @Length(max = L_255) line is also present for other fields like "private String name". So the above suggestion will not work.
Samuel
I am trying to search multiple successive lines.
Samuel
@Samuel: picture added, answer updated to take your full line into account. It will work for multiple successive lines. Give it a try.
VonC
@VonC - thanks, appreciate the detailed response. It works :)
Samuel