Joe
Joe

Reputation: 15311

How do I remove a certain line which has a certain variable using regex

    reportdoc.getAttributes().put(ATT_NAME, "report");
    reportdoc.getAttributes().put(ATT_PIXEL_SIZE, "64");

    clouddoc.getAttributes().put(ATT_NAME, "cloud");
    clouddoc.getAttributes().put(ATT_PIXEL_SIZE, "128");

I would like to remove the entire line in the above file which contains occurences of ATT_PIXEL_SIZE. What regex should I use in eclipse to search and remove the lines.

Upvotes: 4

Views: 2331

Answers (1)

stema
stema

Reputation: 92976

For me this works

^.*ATT_PIXEL_SIZE.*\r\n

and replace with nothing. But I am not sure, can be that you need another linebreak like only \r or \n.

$ will not work because this is a zero width assertion, it will only match between the last character and the end of row, but not the end of row itself.

Upvotes: 8

Related Questions