Multiline search replace with regexp in Eclipse

后端 未结 2 1794
無奈伤痛
無奈伤痛 2020-12-17 10:51

Eclipse regexp search works pretty well, so for example in search box I have this:

(?s)(myMethod.*?;)\\}\\);

Now I want to copy multiline t

相关标签:
2条回答
  • 2020-12-17 11:05

    Generally, the approach I've taken to doing this sort of thing is to type out what I want to use as a replacement, select that, open up the Find/Replace dialog, and copy the contents of the Find text box. I proceed from there and paste what I copied into the Replace text box. There is still a little work to be done (removing backslashes from in front of regex special characters that don't apply in the Replace box), but it gives me a hand up.

    0 讨论(0)
  • 2020-12-17 11:11

    For searching multiple lines in Eclipse, you must use the 's' parameter in search expression:

    (?s)someExpressionToMatchInAnyLine
    

    For replacing with multiple lines exp you must use \R i.e:

    line1\Rline2\Rline3
    

    This will replace the matched exp with:
    line1
    line2
    line3

    0 讨论(0)
提交回复
热议问题