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

Regex to modify URL

Expand Messages
  • ehofferino
    Hi group, Long time reader, first time asker. My goal: To replace this semi-random (i.e. the part after /external/) URL:
    Message 1 of 9 , Dec 14, 2007
    • 0 Attachment
      Hi group,

      Long time reader, first time asker.

      My goal: To replace this semi-random (i.e. the part after /external/) URL:

      http://us.rd.yahoo.com/finance/external/tsmfe/SIG=128vrgsgk/*http://www.thestreet.com/_yahoo/newsanalysis/techtelecom/10394485.html

      with this:

      http://www.thestreet.com/_yahoo/newsanalysis/techtelecom/10394485.html

      In 5.4, I was able to figure this out by doing this:

      ^!replace "http://us.rd.yahoo.com/finance/external/(.*?)[*]" >> "" TWASIR

      When I try the same in 4.95...

      ^!replace "http://us.rd.yahoo.com/finance/external/(.*)[*]" >> "" TWASIR

      (note for some reason I need to remove the "?") which is what I use,
      it removes the asterisk from the original URL but leaves the rest in
      tact, giving me:

      http://us.rd.yahoo.com/finance/external/tsmfe/SIG=128vrgsgk/
      http://www.thestreet.com/_yahoo/newsanalysis/techtelecom/10394485.html

      on two separate lines like that.

      What am I doing wrong?

      Thanks,

      Eli
    • Don - HtmlFixIt.com
      ... Eli, I am just learning regex and have no need/desire to mislearn it in 4.x ... Anyway, if it works as is but for a return being inserted, why not do
      Message 2 of 9 , Dec 15, 2007
      • 0 Attachment
        ehofferino wrote:
        > Hi group,
        >
        > Long time reader, first time asker.
        >
        > My goal: To replace this semi-random (i.e. the part after /external/) URL:
        >
        > http://us.rd.yahoo.com/finance/external/tsmfe/SIG=128vrgsgk/*http://www.thestreet.com/_yahoo/newsanalysis/techtelecom/10394485.html
        >
        > with this:
        >
        > http://www.thestreet.com/_yahoo/newsanalysis/techtelecom/10394485.html
        >
        > In 5.4, I was able to figure this out by doing this:
        >
        > ^!replace "http://us.rd.yahoo.com/finance/external/(.*?)[*]" >> "" TWASIR
        >
        > When I try the same in 4.95...
        >
        > ^!replace "http://us.rd.yahoo.com/finance/external/(.*)[*]" >> "" TWASIR
        >
        > (note for some reason I need to remove the "?") which is what I use,
        > it removes the asterisk from the original URL but leaves the rest in
        > tact, giving me:
        >
        > http://us.rd.yahoo.com/finance/external/tsmfe/SIG=128vrgsgk/
        > http://www.thestreet.com/_yahoo/newsanalysis/techtelecom/10394485.html
        >
        > on two separate lines like that.
        >
        > What am I doing wrong?
        >
        > Thanks,
        >
        > Eli
        >
        Eli,

        I am just learning regex and have no need/desire to "mislearn it" in 4.x
        :-). If you can do it in 5.x why go backwards is my first wonderment.

        Anyway, if it works as is but for a return being inserted, why not do
        your regex, and then simply do a simple replace non-regex?

        Find:
        "^Phttp://www.thestreet.com/_yahoo/newsanalysis/techtelecom/10394485.html"
        and replace with:
        "http://www.thestreet.com/_yahoo/newsanalysis/techtelecom/10394485.html"

        . or dot matches anything except a newline
        * means 0 or more

        If I understand correctly appending the ? to your search makes the
        preceding non-greedy?
      • ehofferino
        ... http://us.rd.yahoo.com/finance/external/tsmfe/SIG=128vrgsgk/*http://www.thestreet.com/_yahoo/newsanalysis/techtelecom/10394485.html ... TWASIR ... TWASIR
        Message 3 of 9 , Dec 15, 2007
        • 0 Attachment
          --- In ntb-clips@yahoogroups.com, "Don - HtmlFixIt.com" <don@...> wrote:
          >
          > ehofferino wrote:
          > > Hi group,
          > >
          > > Long time reader, first time asker.
          > >
          > > My goal: To replace this semi-random (i.e. the part after
          /external/) URL:
          > >
          > >
          http://us.rd.yahoo.com/finance/external/tsmfe/SIG=128vrgsgk/*http://www.thestreet.com/_yahoo/newsanalysis/techtelecom/10394485.html
          > >
          > > with this:
          > >
          > > http://www.thestreet.com/_yahoo/newsanalysis/techtelecom/10394485.html
          > >
          > > In 5.4, I was able to figure this out by doing this:
          > >
          > > ^!replace "http://us.rd.yahoo.com/finance/external/(.*?)[*]" >> ""
          TWASIR
          > >
          > > When I try the same in 4.95...
          > >
          > > ^!replace "http://us.rd.yahoo.com/finance/external/(.*)[*]" >> ""
          TWASIR
          > >
          > > (note for some reason I need to remove the "?") which is what I use,
          > > it removes the asterisk from the original URL but leaves the rest in
          > > tact, giving me:
          > >
          > > http://us.rd.yahoo.com/finance/external/tsmfe/SIG=128vrgsgk/
          > > http://www.thestreet.com/_yahoo/newsanalysis/techtelecom/10394485.html
          > >
          > > on two separate lines like that.
          > >
          > > What am I doing wrong?
          > >
          > > Thanks,
          > >
          > > Eli
          > >
          > Eli,
          >
          > I am just learning regex and have no need/desire to "mislearn it" in
          4.x
          > :-). If you can do it in 5.x why go backwards is my first wonderment.
          >
          > Anyway, if it works as is but for a return being inserted, why not do
          > your regex, and then simply do a simple replace non-regex?
          >
          > Find:
          >
          "^Phttp://www.thestreet.com/_yahoo/newsanalysis/techtelecom/10394485.html"
          > and replace with:
          > "http://www.thestreet.com/_yahoo/newsanalysis/techtelecom/10394485.html"
          >
          > . or dot matches anything except a newline
          > * means 0 or more
          >
          > If I understand correctly appending the ? to your search makes the
          > preceding non-greedy?
          >

          Thanks for replying. I'm stuck with 4.95 because certain changes that
          were evidently made don't really work for me. They're minor things
          with how the program works, yet for me they make a major difference.

          WRT my question, it's not simply that I'm getting an extra hard
          return. It's not deleting the URL at all; it's just putting it on
          another line, whereas I want it deleted.

          I'm sure there's something wrong with the way I'm implementing regex,
          but I don't have enough experience to figure it out.
        • Sheri
          ... You should tell us what you re referring to, maybe we can help. IMO anyone interested in regex is best served by upgrading period. The old regex engine did
          Message 4 of 9 , Dec 15, 2007
          • 0 Attachment
            ehofferino wrote:

            > Thanks for replying. I'm stuck with 4.95 because certain changes that
            > were evidently made don't really work for me. They're minor things
            > with how the program works, yet for me they make a major difference.
            >
            You should tell us what you're referring to, maybe we can help.

            IMO anyone interested in regex is best served by upgrading period. The
            old regex engine did not support non-greedy expressions which is what
            (.*?) is. The old regex engine was also slow, clunky, and unreliable on
            large documents. The one in 5.5 is modern, sleek and fast. It is the
            same regex engine found in php and apache.

            That said, you can try "http://us.rd.yahoo.com/finance/external.+\*"

            I think it would work in 4.95 as long as there's only one asterisk on
            the matching lines.

            Regards,
            Sheri
          • Sheri
            ... Actually, http://us .rd .yahoo .com/finance/external.+ * would be safer since otherwise the dots match any character not just literal periods. Regards,
            Message 5 of 9 , Dec 15, 2007
            • 0 Attachment
              Sheri wrote:
              >
              >
              > That said, you can try "http://us.rd.yahoo.com/finance/external.+\*"
              Actually,

              "http://us\.rd\.yahoo\.com/finance/external.+\*"

              would be safer since otherwise the dots match any character not just literal periods.

              Regards,
              Sheri
            • ehofferino
              ... Thanks for taking the time to respond, Sheri. I tried your solution with the same results. It seems the old regex is good at replacing random text (using
              Message 6 of 9 , Dec 16, 2007
              • 0 Attachment
                --- In ntb-clips@yahoogroups.com, Sheri <silvermoonwoman@...> wrote:
                >
                > ehofferino wrote:
                >
                > > Thanks for replying. I'm stuck with 4.95 because certain changes that
                > > were evidently made don't really work for me. They're minor things
                > > with how the program works, yet for me they make a major difference.
                > >
                > You should tell us what you're referring to, maybe we can help.
                >
                > IMO anyone interested in regex is best served by upgrading period. The
                > old regex engine did not support non-greedy expressions which is what
                > (.*?) is. The old regex engine was also slow, clunky, and unreliable on
                > large documents. The one in 5.5 is modern, sleek and fast. It is the
                > same regex engine found in php and apache.
                >
                > That said, you can try "http://us.rd.yahoo.com/finance/external.+\*"
                >
                > I think it would work in 4.95 as long as there's only one asterisk on
                > the matching lines.
                >
                > Regards,
                > Sheri
                >

                Thanks for taking the time to respond, Sheri.

                I tried your solution with the same results. It seems the "old" regex
                is good at replacing random text (using *) at the end of a string
                (URL) but not at the beginning?

                One of my issues with 5.x is that when I create a "prompt=..." box
                with say 50 entries, and suppose five of them start with the letter
                "J." In 4.95 you could hit J and the J and each time it would take you
                to the NEXT INSTANCE of an entry that starts with J. Now, it doesn't.
                Hitting J takes you to the first instance. Hitting J again just keeps
                you there. If you're lucky, sometimes typing the second letter of the
                second instance (say "Ja") might get you there.

                The same is true when your cursor is in the Clipbook sidebar. In 4.x,
                hitting W more than once would take you to each succeeding instance.
                Now it doesn't.

                Is this some kind of enhancement? Is there a workaround?
              • Sheri
                ... Not sure what the problem is on your end, but I dusted off my old 4.95 and tried it and it worked for me. I had duplicated your sample line a bunch of
                Message 7 of 9 , Dec 18, 2007
                • 0 Attachment
                  --- In ntb-clips@yahoogroups.com, "ehofferino" <eyhoffmann@...> wrote:

                  >
                  > I tried your solution with the same results. It seems the "old"
                  > regex is good at replacing random text (using *) at the end of a
                  > string (URL) but not at the beginning?

                  Not sure what the problem is on your end, but I dusted off my old 4.95
                  and tried it and it worked for me. I had duplicated your sample line a
                  bunch of times, and it fixed them all. Maybe your clip library is
                  corrupted. Try it from a new clip library, and be sure to press the
                  enter key at the end of the line without adding any extra spaces. In
                  Pro you can turn on View Non-printing characters.

                  ^!Replace "http://us\.rd\.yahoo\.com/finance/external.+\*" >> "" WARIS

                  There is no need for a "T" in options for a regular expression.
                  However for me, it worked with and without including a "T" option.

                  The original command you posted made no changes at all to my text.

                  >
                  > One of my issues with 5.x is that when I create a "prompt=..."
                  > box with say 50 entries, and suppose five of them start with the
                  > letter "J." In 4.95 you could hit J and the J and each time it
                  > would take you to the NEXT INSTANCE of an entry that starts with
                  > J. Now, it doesn't. Hitting J takes you to the first instance.
                  > Hitting J again just keeps you there. If you're lucky, sometimes
                  > typing the second letter of the second instance (say "Ja") might
                  > get you there. The same is true when your cursor is in the
                  > Clipbook sidebar. In 4.x, hitting W more than once would take you
                  > to each succeeding instance. Now it doesn't. Is this some kind of
                  > enhancement? Is there a workaround?

                  That's valid. Maybe Eric could change it, it may never have been
                  brought to his attention.

                  Regards,
                  Sheri
                • ehofferino
                  Thanks Sheri! I tried your clip again, and it did indeed work (no corrupted library). Another quirk about 5.x is that I like to (sometimes) use
                  Message 8 of 9 , Dec 27, 2007
                  • 0 Attachment
                    Thanks Sheri!

                    I tried your clip again, and it did indeed work (no corrupted library).

                    Another quirk about 5.x is that I like to (sometimes) use
                    space-bullet-space (i.e. " • ") as my pasteboard separator. For some
                    reason, in 5.x, it seems to ignore the second space.

                    --- In ntb-clips@yahoogroups.com, "Sheri" <silvermoonwoman@...> wrote:
                    >
                    > --- In ntb-clips@yahoogroups.com, "ehofferino" <eyhoffmann@> wrote:
                    >
                    > >
                    > > I tried your solution with the same results. It seems the "old"
                    > > regex is good at replacing random text (using *) at the end of a
                    > > string (URL) but not at the beginning?
                    >
                    > Not sure what the problem is on your end, but I dusted off my old 4.95
                    > and tried it and it worked for me. I had duplicated your sample line a
                    > bunch of times, and it fixed them all. Maybe your clip library is
                    > corrupted. Try it from a new clip library, and be sure to press the
                    > enter key at the end of the line without adding any extra spaces. In
                    > Pro you can turn on View Non-printing characters.
                    >
                    > ^!Replace "http://us\.rd\.yahoo\.com/finance/external.+\*" >> "" WARIS
                    >
                    > There is no need for a "T" in options for a regular expression.
                    > However for me, it worked with and without including a "T" option.
                    >
                    > The original command you posted made no changes at all to my text.
                    >
                    > >
                    > > One of my issues with 5.x is that when I create a "prompt=..."
                    > > box with say 50 entries, and suppose five of them start with the
                    > > letter "J." In 4.95 you could hit J and the J and each time it
                    > > would take you to the NEXT INSTANCE of an entry that starts with
                    > > J. Now, it doesn't. Hitting J takes you to the first instance.
                    > > Hitting J again just keeps you there. If you're lucky, sometimes
                    > > typing the second letter of the second instance (say "Ja") might
                    > > get you there. The same is true when your cursor is in the
                    > > Clipbook sidebar. In 4.x, hitting W more than once would take you
                    > > to each succeeding instance. Now it doesn't. Is this some kind of
                    > > enhancement? Is there a workaround?
                    >
                    > That's valid. Maybe Eric could change it, it may never have been
                    > brought to his attention.
                    >
                    > Regards,
                    > Sheri
                    >
                  • Sheri
                    ... I just tried that pasteboard separator and it works fine for me (NTP version 5.5). You might want to close NoteTab and check your notepro.ini file (e.g.,
                    Message 9 of 9 , Dec 29, 2007
                    • 0 Attachment
                      --- In ntb-clips@yahoogroups.com, "ehofferino" <eyhoffmann@...> wrote:
                      >
                      > Thanks Sheri!
                      >
                      > I tried your clip again, and it did indeed work (no corrupted library).
                      >
                      > Another quirk about 5.x is that I like to (sometimes) use
                      > space-bullet-space (i.e. " • ") as my pasteboard separator. For some
                      > reason, in 5.x, it seems to ignore the second space.
                      >

                      I just tried that pasteboard separator and it works fine for me (NTP
                      version 5.5). You might want to close NoteTab and check your
                      notepro.ini file (e.g., with notepad) and make sure this line is in it:

                      PasteBoardDivider=" • "

                      If you edit your ini file in NoteTab, you have to save it with a an
                      exclamation in front of the file name, then close and reopen NoteTab.
                      No need for that if you use some other program to edit the ini file,
                      but NoteTab should not be running while the changes are made.

                      There could be something else at work. For example, if "Trim White
                      Spaces" is checked under Options|Document, and clipboard text
                      sometimes begins with spaces and line breaks (or just line breaks),
                      then the space after the bullet could get trimmed when the document is
                      saved.

                      Regards,
                      Sheri
                    Your message has been successfully submitted and would be delivered to recipients shortly.