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

Re: [Clip] Re: Clip for getting lines containing

Expand Messages
  • Axel Berger
    ... GetDocMatchAll uses regular expressions where the parentheses have special meaning. So you need to escape them if you mean them literally. Without changing
    Message 1 of 10 , Sep 6, 2008
      gunnisonbirder wrote:
      > First part about finding lines that contain (?) still a mystery.

      GetDocMatchAll uses regular expressions where the parentheses have
      special meaning. So you need to escape them if you mean them
      literally.
      Without changing the clip at all just entering "\(?\)" as your
      search string (without the quotes of course) should do it.

      Axel
    • Axel Berger
      ... Correction: The question mark has a special meaning too, so it really should be ( ? ) . Axel
      Message 2 of 10 , Sep 6, 2008
        Axel Berger wrote:
        > just entering "\(?\)"

        Correction: The question mark has a special meaning too, so it
        really should be "\(\?\)".

        Axel
      • John Shotsky
        If I read what you have written correctly, you don t know what character is going to be between the parens. If that is the case, you would find it as follows:
        Message 3 of 10 , Sep 6, 2008
          If I read what you have written correctly, you don't know what character is going to be between the parens. If that is the case, you
          would find it as follows:

          \(.\)

          The dot means any single character except a line end.

          John

          From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of gunnisonbirder
          Sent: Saturday, September 06, 2008 3:44 AM
          To: ntb-clips@yahoogroups.com
          Subject: [Clip] Clip for getting lines containing

          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.

          And this maybe a different problem, can I adjust clip to get all words
          with proper case (thus removing all words that are all caps)?

          Thanks for any suggestions and advice!



          [Non-text portions of this message have been removed]
        • Flo
          ... Given that the single character in parentheses is a word character, you may try... ^!Set %Search%=^?{Enter search string:} ^!SetListDelimiter ^P ^!Set
          Message 4 of 10 , Sep 6, 2008
            --- 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 5 of 10 , Sep 6, 2008
              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 6 of 10 , Sep 7, 2008
                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 7 of 10 , Sep 7, 2008
                  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 8 of 10 , Sep 8, 2008
                    --- 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.