1

I'm using this regular expression to replace lines that contain -foo:

^.*?(-foo\b).*$

After the replacement, there's a bunch of blank lines left where the lines originally existed. How can I change this to remove the line itself instead of leaving a blank line?

The context that I'm doing this in is an Ant script and here's the full line if it helps:

<replaceregexp file=" ... " match="^.*?(-foo\b).*$" replace="" byline="true" />
M A
  • 71,713
  • 13
  • 134
  • 174
rink.attendant.6
  • 44,500
  • 61
  • 101
  • 156

1 Answers1

1

Disable the line by line processing and change the regular expression to include line separators, replacing every occurrence with a new line.

<replaceregexp file=" ... " match="(\r?\n).*?(-foo\b).*\r?\n" replace="\1" flags="g" />
M A
  • 71,713
  • 13
  • 134
  • 174