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

23833[Clip] Re: Twos and Threes

Expand Messages
  • flo.gehrke
    May 26, 2013
    • 0 Attachment
      --- In ntb-clips@yahoogroups.com, "Adrian Worsfold"<pluralist@...> wrote:
      > ^!Replace "^.*\b(HL|SF|LS|CC|HW|HF|NB)\b.*$" >> "\r\n$0\r\n" WARS
      > etc...

      How do you actually explain such lines?


      Let me just give you an explanation for the first command line:

      Find '^.*\b(HL|SF|LS|CC|HW|HF|NB)\b.*$'...
      ^ = start of line
      .* = any character (except NL), zero or more times
      \b = word boundary (between word character and non-word character)
      (HL|...|NB) = alternation (a OR b OR c etc)
      \b = another word boundary
      .* = again any character till...
      $ = end of line

      And replace with...
      \r\n = CRNL
      $0 = the whole match
      \r\n = another CRNL

      From a stricter point of view, one would write:


      This is a bit more efficient though, with a few lines, one would hardly notice the difference. At the start of each line, we see at least one character being different from '(HL|...|NB)'. So it makes no sense to search for 'zero'. It's the same condition at end of lines where we've got time data.

      Since there's nothing to store, the alternation could be defined as non-capturing with '?:'. So you may want to replace the RegEx in the above mentioned command line with this better version.

      > Once again many thanks are due.

      It's been a pleasure! It keeps me in practice. I also like the precise requirements you are posting, and the good feedback you give including a full view of what comes out in the end.

    • Show all 10 messages in this topic