How do I do this with TPIPE?

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
#1
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.
 
#2
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