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

RE: [Clip] Deleting multiple lines

Expand Messages
  • John Shotsky
    Thanks, Alec, I ll look into that GetDocListAll command. Below is my rather kludgey way of doing it.added fake delimiters, performed a replace, removed the
    Message 1 of 5 , May 4, 2009
    • 0 Attachment
      Thanks, Alec, I'll look into that GetDocListAll command. Below is my rather kludgey way of doing it.added fake
      delimiters, performed a replace, removed the fakes. It works, and it's fast, but obviously it is inelegant.

      ^!Jump Doc_End
      ^!InsertText [[[E
      ^!Jump Doc_Start
      ^!InsertText S]]]
      ^!Jump Doc_Start
      :DumpEmail
      ^!Find "(?s)\]\]\].+?\[\[\[" RS
      ^!IfError EmailDumped
      ^!Replace "(?s)(S?\]\]\]).+?(\[\[\[E?)" >> "$1\n\n$2" RAWS0
      ^!Jump Select_End
      ^!Jump +1
      ^!Goto DumpEmail
      :EmailDumped
      ^!Replace "(\[\[\[E|S\]\]\])" >> "" RAWS0

      John

      From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of Alec Burgess
      Sent: Monday, May 04, 2009 12:20 AM
      To: ntb-clips@yahoogroups.com
      Subject: Re: [Clip] Deleting multiple lines






      John Shotsky (jshotsky@... <mailto:jshotsky%40comcast.net> ) wrote (in part) (on 2009-05-04 at
      00:06):
      > I have a situation where I'd like to delete several lines between two
      > delimiters, multiple times in a file, in addition
      > to leading and trailing 'stuff' that I don't need.
      >
      > Input:
      > Start of file
      > Lines to delete
      > [[[
      > Lines to keep
      > ]]]
      > Any number of lines to be deleted
      > [[[
      > Lines to keep
      > ]]]
      > Several lines to delete
      > [[[
      > More lines to keep
      > ]]]
      > More lines to delete
      > eof

      H="KeepBetweenDelims"
      ^!set %theSearch%="(?sm)(\[{3}\r\n(.*?)\r\n\]{3})"
      ^!Set %allMatches%=^$GetDocListAll("^%theSearch%";"$2^P")$
      ;^!info ^%allMatches%
      ^!select ALL
      ^!inserttext ^%allMatches%

      Note: ^$GetDocListAll()$ and ^$GetDocReplaceAll() were added in 5.7 -
      Prior to them I wasted a lot of time trying to construct regexs that
      would remove unwanted "stuff" by trying to use lookaheads and
      lookbehinds etc.

      These functions - especially ^$GetDocListAll()$ make it easy to find and
      format all the "wanted" stuff - then just replace the entire file with
      the constructed replacement.

      If you want to keep the delimeters as well, change "$2^P" to "$1^P"

      --
      Regards ... Alec (buralex@gmail & WinLiveMess - alec.m.burgess@skype)

      [Non-text portions of this message have been removed]



      [Non-text portions of this message have been removed]
    Your message has been successfully submitted and would be delivered to recipients shortly.