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

Removing numbers from a list

Expand Messages
  • franz_sternbald
    I m trying to remove numbers from a list (pure numbers only, no mixed character classes) using ^!Replace ^ d+ n AWRS The list is... Alabama 1 1-27 B747
    Message 1 of 12 , Nov 27 7:08 AM
      I'm trying to remove numbers from a list (pure numbers only, no mixed
      character classes) using

      ^!Replace "^\d+\n" >> "" AWRS

      The list is...

      Alabama
      1
      1-27
      B747
      99
      345
      ##23
      7
      9
      099
      012
      033
      Colorado

      The result is...

      Alabama
      1-27
      B747
      345 (false)
      ##23
      9 (false)
      012 (false)
      Colorado

      Why are three numbers left although they are matching
      the replace criteria? How could I have this command executed properly?

      Thanks,
      Flo
    • Don - htmlfixit.com
      ... You ll have to ask someone smarter than me, but it must have to do with cursor placement and/or greedy finds or something. I think this does it with
      Message 2 of 12 , Nov 27 8:09 AM
        franz_sternbald wrote:
        >
        > I'm trying to remove numbers from a list (pure numbers only, no mixed
        > character classes) using
        >
        > ^!Replace "^\d+\n" >> "" AWRS
        >
        > The list is...
        >
        > Alabama
        > 1
        > 1-27
        > B747
        > 99
        > 345
        > ##23
        > 7
        > 9
        > 099
        > 012
        > 033
        > Colorado
        >
        > The result is...
        >
        > Alabama
        > 1-27
        > B747
        > 345 (false)
        > ##23
        > 9 (false)
        > 012 (false)
        > Colorado

        You'll have to ask someone smarter than me, but it must have to do with
        cursor placement and/or greedy finds or something. I think this does it
        with repetitive searches ... depending on how big it is it might be a
        solution.

        :Loop
        ^!Replace "^\d+\n" >> "" ATIWRS
        ^!IfError END
        ^!Jump 1
        ^!GoTo Loop
      • hsavage
        ... Flo, I see several messages backed up so I don t know if anyone has helped or not. I don t understand why your formula doesn t work either, but, I m far
        Message 3 of 12 , Nov 27 9:08 AM
          franz_sternbald wrote:
          >
          > I'm trying to remove numbers from a list (pure numbers only, no mixed
          > character classes) using
          >
          > ^!Replace "^\d+\n" >> "" AWRS
          >
          > Why are three numbers left although they are matching
          > the replace criteria? How could I have this command executed properly?
          >
          > Thanks,
          > Flo

          Flo,

          I see several messages backed up so I don't know if anyone has helped or
          not.

          I don't understand why your formula doesn't work either, but, I'm far
          from an expert on regex.

          I solved it with these 2 lines.

          H="XxXxX"
          ^!Replace ^\d+$ >> "" WRSA
          ^!Replace \n+ >> \n WRSA

          I had to delineate BOL with '^' and EOL with $. Throw the \n into the
          mix and I couldn't make it work in any way.

          ºvº
          hrs <04-11-27> hsavage@...
        • Alan
          ^!Replace ^ d+ n AWRS that criteria specifies: one or more digits only, nothing else whatsoever, on a line Are your (false) the problematic, the
          Message 4 of 12 , Nov 27 10:55 AM
            ^!Replace "^\d+\n" >> "" AWRS

            that criteria specifies: "one or more digits only, nothing else whatsoever, on a line"

            Are your (false) the problematic, the issue?

            if so, perhaps they had a space somewher on the line if so, would cause to fail.

            if it is 1 to 3 digits you seek to eliminate then it is a safer bet to be more specific in the regex

            I just saw Harvey's post look like he got a fix for it.

            Ntab regex natively grabs and looks at one line at a time anyway, ^items$

            like harvey did, beginning to end of string is one line at a time.

            differently, you could select line then into var then check it against the IsAlpha or the IsNumeric

            then only if it pass that test, only then, do the regex substitution on such line(s).


            franz_sternbald wrote:
            >
            > I'm trying to remove numbers from a list (pure numbers only, no mixed
            > character classes) using
            >
            > ^!Replace "^\d+\n" >> "" AWRS
            >
            > The list is...
            >
            > Alabama
            > 1
            > 1-27
            > B747
            > 99
            > 345
            > ##23
            > 7
            > 9
            > 099
            > 012
            > 033
            > Colorado
            >
            > The result is...
            >
            > Alabama
            > 1-27
            > B747
            > 345 (false)
            > ##23
            > 9 (false)
            > 012 (false)
            > Colorado
            >
            > Why are three numbers left although they are matching
            > the replace criteria? How could I have this command executed properly?
            >
            > Thanks,
            > Flo
          • franz_sternbald
            Hi, @Alan ... Certainly, there is no space on these lines. When searching in that list with the Find or Replace command in the menu it s no problem to find all
            Message 5 of 12 , Nov 27 3:29 PM
              Hi,

              @Alan

              > Are your (false) the problematic, the issue? If so,
              > perhaps they had a space somewher on the line if so,
              > would cause to fail.

              Certainly, there is no space on these lines. When searching in that
              list with the Find or Replace command in the menu it's no problem to
              find all numbers. When running a clip with the same RegEx, there
              always are three numbers (marked with "false") left that have not
              been found.

              If that RegEx is being executed multiple times as proposed by Don
              finally all numbers will be removed.

              However, I'll follow your advice to check each line against IsAlpha
              or IsNumeric. The work-around mentioned by Harvey also works fine!

              Thanks to all of you for your help! :-)

              Franz
            • Josh - CK
              NTB Search and replace seem to have a bug, after a replace it picks up on the line after the one it left on if your search ends with a CR. If you advance the
              Message 6 of 12 , Nov 30 6:53 PM
                NTB Search and replace seem to have a bug, after a replace it picks up
                on the line after the one it left on if your search ends with a CR.
                If you advance the search manualy it does it correctly, but if you
                'replace all' it misses lines directly following a previous hit. I'm
                not sure if it's only broken with Regexp, since I pretty much always
                use Regexp.


                On Sat, 27 Nov 2004 23:29:18 -0000, franz_sternbald
                <franz_sternbald@...> wrote:
                >
                >
                > Hi,
                >
                > @Alan
                >
                > > Are your (false) the problematic, the issue? If so,
                > > perhaps they had a space somewher on the line if so,
                > > would cause to fail.
                >
                > Certainly, there is no space on these lines. When searching in that
                > list with the Find or Replace command in the menu it's no problem to
                > find all numbers. When running a clip with the same RegEx, there
                > always are three numbers (marked with "false") left that have not
                > been found.
                >
                > If that RegEx is being executed multiple times as proposed by Don
                > finally all numbers will be removed.
                >
                > However, I'll follow your advice to check each line against IsAlpha
                > or IsNumeric. The work-around mentioned by Harvey also works fine!
                >
                > Thanks to all of you for your help! :-)
                >
                > Franz
                >
                >
                >
                >
                >
                > Yahoo! Groups Links
                >
                >
                >
                >
                >


                --
                Josh Simmons - CK
              • abairheart
                Franz, let me add my two cents worth to the finding of numbers with regexp in NoteTab: I have found, that NoteTab does not recognize escaped characters as well
                Message 7 of 12 , Dec 1, 2004
                  Franz,

                  let me add my two cents worth to the finding of numbers with regexp
                  in NoteTab:

                  I have found, that NoteTab does not recognize escaped characters as
                  well as character classes. Whenever I search for digits, I use 0-9.

                  In your case:

                  ^!Replace "^[0-9]+$"(tab)""(tab)RIS

                  Placing quotes around the search string ALSO confuses NoteTab at
                  times. So the search command above will also work without the quotes!
                  In other words, two consecutive tabs will replace the search string
                  with nothing

                  Abair
                • Alec Burgess
                  ... FWIW, I ve found the most unambiguous notation for replace strings in regexp clip lines is: ^!replace find-string-quoted replace-string-quoted R
                  Message 8 of 12 , Dec 1, 2004
                    > Placing quotes around the search string ALSO confuses
                    > NoteTab at times.

                    FWIW, I've found the most unambiguous notation for replace strings in regexp
                    clip lines is:

                    ^!replace "find-string-quoted" >> "replace-string-quoted" R
                    and-other-options

                    Regards ... Alec
                    --


                    ---- Original Message ----
                    From: "abairheart" <abairheart@...>
                    To: <ntb-clips@yahoogroups.com>
                    Sent: Wednesday, December 01, 2004 15:33
                    Subject: [gla: Re: [Clip] Removing numbers from a list

                    > Franz,
                    >
                    > let me add my two cents worth to the finding of numbers
                    > with regexp
                    > in NoteTab:
                    >
                    > I have found, that NoteTab does not recognize escaped
                    > characters as well as character classes. Whenever I
                    > search for digits, I use 0-9.
                    >
                    > In your case:
                    >
                    > ^!Replace "^[0-9]+$"(tab)""(tab)RIS
                    >
                    > Placing quotes around the search string ALSO confuses
                    > NoteTab at times. So the search command above will also
                    > work without the quotes! In other words, two consecutive
                    > tabs will replace the search string with nothing
                  • franz_sternbald
                    Hi all, @ Josh ... I have to confirm that bug. NoteTab is doing exactly what you wrote. @Abair ... Maybe. In a clip, however, I don t see any difference
                    Message 9 of 12 , Dec 3, 2004
                      Hi all,

                      @ Josh

                      > NTB Search and replace seem to have a bug, after
                      > a replace it picks up on the line after the one
                      > it left on if your search ends with a CR.
                      > If you advance the search manualy it does it correctly,
                      > but if you 'replace all' it misses lines directly
                      > following a previous hit.

                      I have to confirm that bug. NoteTab is doing exactly what you wrote.

                      @Abair

                      > I have found, that NoteTab does not recognize escaped
                      > characters as well as character classes. Whenever I search
                      > for digits, I use 0-9.

                      Maybe. In a clip, however, I don't see any difference between ^\d+$
                      and ^[0-9]+$. I get into trouble when trying to remove the empty line
                      that's left when a number has been deleted. That is,...

                      ^!Replace "^[0-9]+" >> ""

                      works fine, but...

                      ^!Replace "^[0-9]+\n" >> ""

                      will leave behind a lot of undeleted numbers. As Alan said, we are
                      better off when checking it against IsNumeric. Having tested all your
                      recommendations, I come to the following synthesis. A clip that
                      reliably deletes all numbers from list could be...

                      ^!Jump 1

                      :Loop
                      ^!IfTrue ^$IsNumber(^$GetLine$)$ Next Else ^!Jump +1
                      ^!Replace "^[0-9]+$\n" >> "" RS
                      ^!IfError End
                      ^!GoTo Loop

                      :End

                      I tested it with a list of 10,000 lines. All numbers (integers) were
                      completely removed.

                      Regards,
                      Franz
                    • abairheart
                      ... in regexp ... Hehehe, so which is i, to find the string-quoted at the start of a line? ^!Find ^ string-quoted ^!Find ^string-quoted ? Varies depeding on
                      Message 10 of 12 , Dec 3, 2004
                        --- In ntb-clips@yahoogroups.com, "Alec Burgess" <burale@a...> wrote:
                        > > Placing quotes around the search string ALSO confuses
                        > > NoteTab at times.
                        >
                        > FWIW, I've found the most unambiguous notation for replace strings
                        in regexp
                        > clip lines is:
                        >
                        > ^!replace "find-string-quoted" >> "replace-string-quoted" R
                        > and-other-options
                        >
                        > Regards ... Alec

                        Hehehe,

                        so which is i, to find the string-quoted at the start of a line?

                        ^!Find ^"string-quoted"
                        ^!Find "^string-quoted" ?


                        Varies depeding on what else is in the string.


                        Abair
                      • Jody
                        Hi Abair & Alec, ... Could one of you kindly tell me what in the world you are talking about starting right after the for what it s worth? You have me
                        Message 11 of 12 , Dec 3, 2004
                          Hi Abair & Alec,

                          >--- In ntb-clips@yahoogroups.com, "Alec Burgess" <burale@a...> wrote:
                          >> > Placing quotes around the search string ALSO confuses
                          >> > NoteTab at times.
                          >>
                          >> FWIW, I've found the most unambiguous notation for replace
                          >> strings in regexp clip lines is:
                          >>
                          >> ^!replace "find-string-quoted" >> "replace-string-quoted" R
                          >> and-other-options
                          >>
                          >> Regards ... Alec
                          >
                          >Hehehe,
                          >
                          >so which is i, to find the string-quoted at the start of a line?
                          >
                          >^!Find ^"string-quoted"
                          >^!Find "^string-quoted" ?
                          >
                          >Varies depeding on what else is in the string.

                          Could one of you kindly tell me what in the world you are talking
                          about starting right after the for what it's worth? You have me
                          completely lost. Thanks!

                          See ya in the funnies,
                          Jody Adair, Prov. 15:15

                          Blessed are they who can laugh at themselves
                          for they shall never cease to be amused.
                          http://www.clean-funnies.com
                        • Alan C.
                          On Fri, 03 Dec 2004 22:47:20 -0000, abairheart wrote: [ . . ] ... Supposed to be (I think) all inside the quotes with nothing to the left of the left hand
                          Message 12 of 12 , Dec 3, 2004
                            On Fri, 03 Dec 2004 22:47:20 -0000, abairheart wrote:
                            [ . . ]
                            > so which is i, to find the string-quoted at the start of a line?
                            >
                            > ^!Find ^"string-quoted"
                            > ^!Find "^string-quoted" ?

                            Supposed to be (I think) all inside the quotes with nothing to the left of the left hand quote.

                            Have you also tested/tried:

                            ^!Find "^(string-quoted)"

                            ()

                            grouping. above, just 1 group. next, 3 potential to find (each of the 3 is a group)

                            ^!Find "^(string-quoted1)|(string-quoted2)|(string-quoted3)"

                            --
                            Alan.
                          Your message has been successfully submitted and would be delivered to recipients shortly.