1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How do I do this with TPIPE?

Discussion in 'Support' started by vefatica, Mar 11, 2015.

  1. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,972
    Likes Received:
    30
    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. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,972
    Likes Received:
    30
    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
     

Share This Page