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

RegEx to replace strings -- not working?

Expand Messages
  • maxgrenkowitz
    Hello Good People, I am trying to replace numbers with dashes between them to numbers with dashes. It is required for referencing e.g. page numbers: 23-44,
    Message 1 of 6 , Aug 5, 2004
    • 0 Attachment
      Hello Good People,

      I am trying to replace numbers with dashes between them to numbers
      with dashes.
      It is required for referencing e.g. page numbers: 23-44, which
      should really be 23–44

      The following RegEx (running in a clip) changes my find string to
      nothing:
      ^!Replace "\d-\d" >> "\1\–\2" AISHR

      Can someone point me into the right direction or even a correction,
      please?

      Thanks and regards,
      Max
    • Alan
      ... ^!Replace { d+}-{ d+} 1– 2 ISHR ^!Replace { d d?}-{ d d?} 1– 2 ISHR (untested) either of those meant as a one liner for the
      Message 2 of 6 , Aug 5, 2004
      • 0 Attachment
        maxgrenkowitz wrote:
        > Hello Good People,
        >
        > I am trying to replace numbers with dashes between them to numbers
        > with dashes.
        > It is required for referencing e.g. page numbers: 23-44, which
        > should really be 23–44
        >
        > The following RegEx (running in a clip) changes my find string to
        > nothing:
        > ^!Replace "\d-\d" >> "\1\–\2" AISHR

        ^!Replace "{\d+}-{\d+}" >> "\1–\2" ISHR

        ^!Replace "{\d\d?}-{\d\d?}" >> "\1–\2" ISHR

        (untested) either of those meant as a one liner for the task.

        tagged match makes use of those curly braces. each tagged gets put back
        (\1 and the \2) whilst the - in between gets replaced with something
        different.

        H option forces to selected area only, A is for all in doc (from cursor
        position. R of course is for regex

        regex is in the other of the two help files, not in the clip programming
        help.
        --

        shift + F12

        turn on the non-printing, look REAL closely for character 26 in the clip
        since char 26 masquerades as a space while it's not a space and it ruins
        clips too.
        --
        Alan.
      • Alec Burgess
        ... not tested, but I think the find string s/b: { d+}-{ d+} d only matches a single digit, putting the + on matches a continuous string of dashes. the
        Message 3 of 6 , Aug 5, 2004
        • 0 Attachment
          > ^!Replace "\d-\d" >> "\1\–\2" AISHR

          not tested, but I think the find string s/b:

          "{\d+}-{\d+}"

          \d only matches a single digit, putting the + on matches a continuous string
          of dashes.
          the brace brackets around the {\d+}'s indicates whatever it matches is to be
          available on the replace side as: \1 \2 \3,..., \9


          Regards ... Alec
          --


          ---- Original Message ----
          From: "maxgrenkowitz" <maxg@...>
          To: <ntb-clips@yahoogroups.com>
          Sent: Thursday, August 05, 2004 23:16
          Subject: [gla: [Clip] RegEx to replace strings -- not
          working?

          > Hello Good People,
          >
          > I am trying to replace numbers with dashes between them
          > to numbers with dashes.
          > It is required for referencing e.g. page numbers: 23-44,
          > which
          > should really be 23–44
          >
          > The following RegEx (running in a clip) changes my find
          > string to nothing:
          > ^!Replace "\d-\d" >> "\1\–\2" AISHR
          >
          > Can someone point me into the right direction or even a
          > correction, please?
          >
          > Thanks and regards,
          > Max
          >
          >
          >
          >
          > ------------------------ Yahoo! Groups Sponsor
          > --------------------~--> Yahoo! Domains - Claim yours for
          > only $14.70
          > http://us.click.yahoo.com/Z1wmxD/DREIAA/yQLSAA/dkFolB/TM
          > --------------------------------------------------------------------~->
          >
          >
          > Yahoo! Groups Links
          >
          >
          >
        • maxgrenkowitz
          Huh... :) This does the trick. the curly brackets are the key thing. Thanks Alec! The + after d is not required in this case, because 321-123 21-12 1-1 will
          Message 4 of 6 , Aug 6, 2004
          • 0 Attachment
            Huh... :) This does the trick. the curly brackets are the key thing.

            Thanks Alec!

            The + after \d is not required in this case, because
            321-123
            21-12
            1-1

            will replace in all case 1-1, and as such doing what it is supposed
            to.

            Brilliant, thanks a lot.




            --- In ntb-clips@yahoogroups.com, "Alec Burgess" <burale@a...> wrote:
            > > ^!Replace "\d-\d" >> "\1\–\2" AISHR
            >
            > not tested, but I think the find string s/b:
            >
            > "{\d+}-{\d+}"
            >
            > \d only matches a single digit, putting the + on matches a
            continuous string
            > of dashes.
            > the brace brackets around the {\d+}'s indicates whatever it
            matches is to be
            > available on the replace side as: \1 \2 \3,..., \9
            >
            >
            > Regards ... Alec
            > --
            >
            >
            > ---- Original Message ----
            > From: "maxgrenkowitz" <maxg@d...>
            > To: <ntb-clips@yahoogroups.com>
            > Sent: Thursday, August 05, 2004 23:16
            > Subject: [gla: [Clip] RegEx to replace strings -- not
            > working?
            >
            > > Hello Good People,
            > >
            > > I am trying to replace numbers with dashes between them
            > > to numbers with dashes.
            > > It is required for referencing e.g. page numbers: 23-44,
            > > which
            > > should really be 23–44
            > >
            > > The following RegEx (running in a clip) changes my find
            > > string to nothing:
            > > ^!Replace "\d-\d" >> "\1\–\2" AISHR
            > >
            > > Can someone point me into the right direction or even a
            > > correction, please?
            > >
            > > Thanks and regards,
            > > Max
            > >
            > >
            > >
            > >
            > > ------------------------ Yahoo! Groups Sponsor
            > > --------------------~--> Yahoo! Domains - Claim yours for
            > > only $14.70
            > > http://us.click.yahoo.com/Z1wmxD/DREIAA/yQLSAA/dkFolB/TM
            > > -----------------------------------------------------------------
            ---~->
            > >
            > >
            > > Yahoo! Groups Links
            > >
            > >
            > >
          • maxgrenkowitz
            Oops... I didn t see this reply... sorry. Thanks Alan for the hints; checked it out right away :) Cheers, Max ... numbers ... to ... put back ... something ...
            Message 5 of 6 , Aug 6, 2004
            • 0 Attachment
              Oops... I didn't see this reply... sorry.

              Thanks Alan for the hints; checked it out right away :)

              Cheers,
              Max



              --- In ntb-clips@yahoogroups.com, Alan <acumming@c...> wrote:
              > maxgrenkowitz wrote:
              > > Hello Good People,
              > >
              > > I am trying to replace numbers with dashes between them to
              numbers
              > > with dashes.
              > > It is required for referencing e.g. page numbers: 23-44, which
              > > should really be 23–44
              > >
              > > The following RegEx (running in a clip) changes my find string
              to
              > > nothing:
              > > ^!Replace "\d-\d" >> "\1\–\2" AISHR
              >
              > ^!Replace "{\d+}-{\d+}" >> "\1–\2" ISHR
              >
              > ^!Replace "{\d\d?}-{\d\d?}" >> "\1–\2" ISHR
              >
              > (untested) either of those meant as a one liner for the task.
              >
              > tagged match makes use of those curly braces. each tagged gets
              put back
              > (\1 and the \2) whilst the - in between gets replaced with
              something
              > different.
              >
              > H option forces to selected area only, A is for all in doc (from
              cursor
              > position. R of course is for regex
              >
              > regex is in the other of the two help files, not in the clip
              programming
              > help.
              > --
              >
              > shift + F12
              >
              > turn on the non-printing, look REAL closely for character 26 in
              the clip
              > since char 26 masquerades as a space while it's not a space and it
              ruins
              > clips too.
              > --
              > Alan.
            • hsavage
              ... maxgrenkowitz, ^!Replace { d+} -{ d+} 1 – 2 ISHRA -Worksforme 1-55 2-3 22-44 66-77 On the Find side the surrounding characters are curly braces,
              Message 6 of 6 , Aug 6, 2004
              • 0 Attachment
                maxgrenkowitz wrote:
                > Hello Good People,
                >
                > I am trying to replace numbers with dashes between them to numbers
                > with dashes.
                > It is required for referencing e.g. page numbers: 23-44, which
                > should really be 23–44
                >
                > The following RegEx (running in a clip) changes my find string to
                > nothing:
                > ^!Replace "\d-\d" >> "\1\–\2" AISHR
                >
                > Can someone point me into the right direction or even a correction,
                > please?
                >
                > Thanks and regards,
                > Max
                >
                >
                >
                >
                >
                >
                > Yahoo! Groups Links
                >
                >
                >

                maxgrenkowitz,

                ^!Replace {\d+}\-{\d+} >> \1\–\2 ISHRA
                -Worksforme

                1-55
                2-3
                22-44
                66-77

                On the Find side the surrounding characters are curly braces, not parens.

                Works when list is selected or any members of list are selected. The
                'H' option restricts the replace function to pre-selected numbers.
                Remove option 'H' if numbers are not pre-selected.

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