How to remove an entire line which matches a patte

2019-04-18 14:27发布

问题:

The following pattern matches an entire line, how do I search and remove these lines. If I leave a space in the replace string, it leaves a blank in that particular line, when I do via eclipse.

^[\t ]*<param name="logic" .*$

回答1:

I don't know anything about eclipse but you may need to include the \n newline match in order to remove the line completely. Also - is it possible to replace with an empty string as opposed to a space?

^[\t ]*<param name="logic" .*\n$


回答2:

To delete the line, you must also remove the line-break, not only the contents of the line. So your Expression should end with \r\n instead of $. Can't try it at the moment, so you will have to experiment yourself for the correct syntax.