21847Re: [Clip] Remove all lines not containing something
- Jun 29, 2011I wrote:
>A funky one-line take could be something like:
> I understand the objective to be removal of lines in which certain
> terms are absent.
^!Replace "^((.*\.(org|net).*)|.++)(\R|\Z)(?(2)\K)" >> "" WARS
... where the "(?(2)\K)" bit is a conditional subpatern that checks if $2, that is the "(.*\.(org|net).*)" substring was captured, and if so, resets the whole capture with \K to nothing, so the empty replacement leaves this line intact. When $2 isn't captured, the selection remains ready for its subsequent wipe-out.
- << Previous post in topic Next post in topic >>