Loading ...
Sorry, an error occurred while loading the content.

21855Re: [Clip] Remove all lines not containing something

Expand Messages
  • Don
    Jun 30, 2011
    • 0 Attachment
      > Hi Don,
      >
      > You gave us two conditions now...
      >
      >> I want to essentially ask for data that I do not want to find
      >> in a line... (#21836)
      >
      > and
      >
      >> ...so I literally only know what I want, not what I
      >> don't want. (#21850).

      You may be right -- this is hard to explain. I guess ... I think ...
      maybe ... what I want is to say in the end leave all lines that contain
      one or more pieces of data, and delete/remove all other lines.

      I tried to come up with an easy example, but didn't mean to limit the
      project to that particular set of data. I hope this can be universal.

      I think we are getting really close.

      In fact the three line clip I posted yesterday or so does what I want
      ... I think.

      But this negative and positive look about stuff is interesting and worth
      discussion and my learning even more.

      Your look behind works only if it is at the end of the line.

      I will give some examples:
      http://michigancrosscountry.com/wp-content/uploads/Region-1-1-Boys.txt

      Say I want everyone listed from Grand Blanc and Alpena ...

      so I use:
      ^!Replace "^(?!.*(Grand Blanc|Alpena).*$).+(\R|\Z)" >> "" WARS

      1 Omar Kaddurah 12 Grand Blanc 15:37.28 1
      6 Drake Carr 12 Grand Blanc 16:18.58 6
      8 Zachary Kughn 11 Grand Blanc 16:25.06 8
      13 Jalen Payne 12 Grand Blanc 16:40.68 13
      22 Scott Baughan 12 Grand Blanc 16:50.48 22
      23 Nicholas Lefler 12 Grand Blanc 16:51.02 23
      25 Carson Truesdell 10 Grand Blanc 16:56.10 25
      33 Ethan Crowell 10 Alpena 17:10.37 33
      46 R.J. Centala 9 Alpena 17:22.42 46
      50 Jared Labarge 11 Alpena 17:36.46 50
      51 Travis LaCross 11 Alpena 17:37.60 51
      53 Jacob Benson 10 Alpena 17:40.54 53
      69 Alexander Guzman 11 Alpena 18:14.48 69
      71 Nathan LaBarge 12 Alpena 18:17.02 71



      1 Grand Blanc 50 1 6 8 13 22 23 25
      10 Alpena 233 33 46 50 51 53 69 71


      Answer is I believe correct.

      So now I make it a two liner:
      ^!Set %DataTested%=^?{RegEx Term to Search For, Pipe Separated "or"}
      ^!Replace "^(?!.*(^%DataTested).*$).+(\R|\Z)" >> "" WARS

      Now what if Grand Blanc is the first or last thing on a line ....?

      Seems to still work:
      1 Omar Kaddurah 12 Grand Blanc 15:37.28 1
      6 Drake Carr 12 Grand Blanc 16:18.58 6
      Grand Blanc 8 Zachary Kughn 11 Grand Blanc
      16:25.06 8
      13 Jalen Payne 12 Grand Blanc
      22 Scott Baughan 12 Grand Blanc 16:50.48 22
      [deleted rest]

      I think I now have a universal "delete all lines not containing [fill in
      the blank using regex terms]" clip.
      It has not keyboard commands and appears to be blinding fast.
    • Show all 30 messages in this topic