How to search and replace 2 lines (together) in Eclipse?

后端 未结 5 1987
青春惊慌失措
青春惊慌失措 2020-12-07 22:19

I would like to search multiple files via eclipse for the following 2 lines:

@Length(max = L_255)
private String description;

and replace t

5条回答
  •  佛祖请我去吃肉
    2020-12-07 23:02

    A quick tip for including multiple lines as part of a manually constructed regular expression:

    Where you would normally use .* to match any character zero or more times, instead consider using something like (?:.|\r?\n)*. Or put an extra ? at the end to make it non-greedy.

    Explanation: . doesn't match new lines so need to do an "either-or": The parentheses match either the . before the pipe or the new line after it. The ? after \r makes the carriage return before the line feed optional to allow Windows or Unix new lines. The ?: excludes the whole thing as a capturing group (which helps to avoid a stack overflow).

提交回复
热议问题