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

Re: Clip for getting lines containing

Expand Messages
  • Flo
    ... Given that the single character in parentheses is a word character, you may try... ^!Set %Search%=^?{Enter search string:} ^!SetListDelimiter ^P ^!Set
    Message 1 of 10 , Sep 6, 2008
    • 0 Attachment
      --- In ntb-clips@yahoogroups.com, "gunnisonbirder"
      <gunnisonbirder@...> wrote:
      >
      > I am using following clip for getting lines containing "search
      > string"
      > ^!Set %Search%=^?{Enter search string:}...
      > Is it possible and how can I adjust clip to get lines containing (?)
      > where there is one letter between parentheses? (?) always appears
      > at the end of the line of list of 500 names.

      Given that the single character in parentheses is a word character,
      you may try...

      ^!Set %Search%=^?{Enter search string:}
      ^!SetListDelimiter ^P
      ^!Set %Lines%=^$GetDocMatchAll("^.*^%Search%.*\(\w\)(?=\R|\Z)")$
      ^!Toolbar New Document
      ^!InsertText ^%Lines%

      The position of (x) at end of line is forced by a Positive Lookahead
      Assertion. That is, (x) matches before a CR/NL or at end of list
      (followed by an empty line or not).

      When searching for "fredo" in the following list...

      Alfredo (a)
      Alfredo (!)
      Alfredo (b) Garcia
      Bertha
      Carla
      David
      Alfredo (c)

      the output will be...

      Alfredo (a)
      Alfredo (c)

      The second and third line are not matched because (!) is no word
      character and the (b) is not at end of line.

      Regards,
      Flo


      P.S. Maybe it's worth a mention here that ^$GetDocMatchAll$ doesn't
      allow to define the end of line with $. In "Search | Find" we get the
      same result with ^.*fredo.*\(\w\)$. But we cannot write...

      ^!Set %Lines%=^$GetDocMatchAll("^.*^%Search%.*\(\w\)$")$

      In this case, NT reacts with "Regex error: \ at end of pattern". So
      the job is done with that Assertion. Strange enough, we also can
      replace the $ with ^%Dollar%...

      ^!Set %Lines%=^$GetDocMatchAll("^.*^%Search%.*\(\w\)^%Dollar%")$
    • Don Daugherty
      ... If I understand correctly, your (?) means any one of these: (A), (B), ...,(Z), (a), (b),..., (z), and it must occur at the line end. In that case, I would
      Message 2 of 10 , Sep 6, 2008
      • 0 Attachment
        gunnisonbirder wrote:
        > I am using following clip for getting lines containing "search string"
        >
        > ^!Set %Search%=^?{Enter search string:}
        > ^!SetListDelimiter ^P
        > ^!Set %Lines%=^$GetDocMatchAll(^.*^%Search%.*$)$
        > ^!Toolbar New Document
        > ^!InsertText ^%Lines%
        >
        > Is it possible and how can I adjust clip to get lines containing (?)
        > where there is one letter between parentheses? (?) always appears at
        > the end of the line of list of 500 names.
        >
        >
        If I understand correctly, your (?) means any one of these: (A), (B),
        ...,(Z), (a), (b),..., (z), and it must occur at the line end.
        In that case, I would use this for my search string: "^.?\([A-Za-z]\)\r\n"
      • gunnisonbirder
        Thanks much for all your help. (? ) and (. ) both worked fine. I used (? ) The (?) where ? equals any letter does not have to be at the end of the line. It
        Message 3 of 10 , Sep 7, 2008
        • 0 Attachment
          Thanks much for all your help.

          \(?\) and \(.\) both worked fine. I used \(?\)

          The (?) where ? equals any letter does not have to be at the end of
          the line. It just happens to be there (I mentioned that in case that
          offered other possibilities in the clip).

          Thanks again you all saved me hours of work as last year I had to
          manually delete lines that did not contain (?)
        • Axel Berger
          ... That s funny. Thickheaded dumbass that I am, I had misunderstood you were looking for an actual question mark and not some letter in that space. A question
          Message 4 of 10 , Sep 7, 2008
          • 0 Attachment
            gunnisonbirder wrote:
            > \(?\) and \(.\) both worked fine.

            That's funny. Thickheaded dumbass that I am, I had misunderstood you
            were looking for an actual question mark and not some letter in that
            space. A question mark as placeholder is not a regex syntax I'm
            aware of. Still, glad everything works now.

            Axel
          • gunnisonbirder
            ... As it turned out (? ) and (. ) don t both seek out one letter. Since most of my lines were (one letter) both clips appeared to work. I accidentally had
            Message 5 of 10 , Sep 8, 2008
            • 0 Attachment
              --- In ntb-clips@yahoogroups.com, Axel Berger <Axel-Berger@...> wrote:
              >
              > gunnisonbirder wrote:
              > > \(?\) and \(.\) both worked fine.
              >
              > That's funny. Thickheaded dumbass that I am, I had misunderstood you
              > were looking for an actual question mark and not some letter in that
              > space. A question mark as placeholder is not a regex syntax I'm
              > aware of. Still, glad everything works now.
              >
              > Axel
              >

              As it turned out \(?\) and \(.\) don't both "seek out" one letter.
              Since most of my lines were (one letter) both clips appeared to work.
              I accidentally had one line with (two letters).
              \(?\) returned one and two letters in the parentheses while
              \(.\) returns lines with only one letter in the parentheses (which is
              what I needed).

              Thanks again for all the help! I was able to look at all the examples
              and write two additional clips that reduced my working time even more.
            Your message has been successfully submitted and would be delivered to recipients shortly.