Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

How do I do this with TPIPE?

May
12,846
164
I have lines like
Code:
variable length unwanted stuff KEYWORD wanted stuff
And I want to filter them so I wind up with
Code:
KEYWORD wanted stuff
How do I do that?

/replace with "extract" (all non-matching test is discarded) looks promising but I also have to tell it what to replace "KEYWORD.*" with and there doesn't seem to be a way to tell it to replace it with itself.
 
I have lines like
Code:
variable length unwanted stuff KEYWORD wanted stuff
And I want to filter them so I wind up with
Code:
KEYWORD wanted stuff
How do I do that?

/replace with "extract" (all non-matching test is discarded) looks promising but I also have to tell it what to replace "KEYWORD.*" with and there doesn't seem to be a way to tell it to replace it with itself.
Got it! As DataMystic puts it ...

Code:
The text matches by a capturing sub pattern can be referred to later (such as in the replacement string) using the
macros $0 (for the full matching text), $1 (for the first sub pattern), $2 ... $9, $a ...$z etc.

Perhaps the help might be made to mention that.

So ...
Code:
/replace=4,0,0,0,0,1,0,0,0,"KEYWORD.*$",$0\n
 

Similar threads

Back
Top