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

$1 in regular expression replace function not recognized

Expand Messages
  • mycroft_b
    NoteTab Light version 5.61 on XP SP3 machine. I want to replace dates formatted as mm/dd/yy as mm/dd/yyyy. Example 07/29/08 changes to 07/29/2008. I set up my
    Message 1 of 4 , Oct 3, 2008
    • 0 Attachment
      NoteTab Light version 5.61 on XP SP3 machine.

      I want to replace dates formatted as mm/dd/yy as mm/dd/yyyy. Example
      07/29/08 changes to 07/29/2008.

      I set up my search and replace as Reg Expr (\d\d/\d\d/)0(\d\s) and
      replace with $12000$2.
      I checked the box for Regular Expression.

      I thought this would find two digits, a forward slash, two digits, a
      forward slash, a zero, a digit, then white space and replace it with
      the first group (07/29/) then 200 then the second group (8 and white
      space).

      It FINDS ok, but replaces this example with $12008. For some reason,
      the first group ($1) is not recognized in the replace although the
      second group ($2) is.

      I would be happy to get this to work even though I know I would have
      to make changes to do the dates before 2000. Also, I'm not sure if
      this would work if date was the only thing on the line instead of
      being followed by white space such as spaces and tabs. But I just
      don't know why this example is not working!

      Thanks!
    • Alex Plantema
      ... It looks like NoteTab is confused because $1 is followed by a digit. But replacing ( d d/ d d)/0( d s) by $1/200$2 does work. Alex.
      Message 2 of 4 , Oct 3, 2008
      • 0 Attachment
        Op vrijdag 3 oktober 2008 20:23 schreef mycroft_b:

        > I want to replace dates formatted as mm/dd/yy as mm/dd/yyyy. Example
        > 07/29/08 changes to 07/29/2008.
        >
        > I set up my search and replace as Reg Expr (\d\d/\d\d/)0(\d\s) and
        > replace with $12000$2.
        > I checked the box for Regular Expression.
        ...
        > It FINDS ok, but replaces this example with $12008. For some reason,
        > the first group ($1) is not recognized in the replace although the
        > second group ($2) is.

        It looks like NoteTab is confused because $1 is followed by a digit.
        But replacing (\d\d/\d\d)/0(\d\s) by $1/200$2 does work.

        Alex.
      • David Smart
        Or put an extra backslash in to force the 2 to a literal, and thus separate it from the $1 ... $1 2000$2 BTW you have too many zeroes in your replacement
        Message 3 of 4 , Oct 3, 2008
        • 0 Attachment
          Or put an extra backslash in to force the 2 to a literal, and thus separate
          it from the $1 ...

          $1\2000$2

          BTW you have too many zeroes in your replacement expression - it currently
          makes 20008 instead of 2008.

          Regards, Dave S

          ----- Original Message -----
          From: "Alex Plantema" <alex.plantema@...>
          To: <notetab@yahoogroups.com>
          Sent: Saturday, October 04, 2008 7:07 AM
          Subject: Re: [NTB] $1 in regular expression replace function not recognized


          > Op vrijdag 3 oktober 2008 20:23 schreef mycroft_b:
          >
          >> I want to replace dates formatted as mm/dd/yy as mm/dd/yyyy. Example
          >> 07/29/08 changes to 07/29/2008.
          >>
          >> I set up my search and replace as Reg Expr (\d\d/\d\d/)0(\d\s) and
          >> replace with $12000$2.
          >> I checked the box for Regular Expression.
          > ...
          >> It FINDS ok, but replaces this example with $12008. For some reason,
          >> the first group ($1) is not recognized in the replace although the
          >> second group ($2) is.
          >
          > It looks like NoteTab is confused because $1 is followed by a digit.
          > But replacing (\d\d/\d\d)/0(\d\s) by $1/200$2 does work.
          >
          > Alex.
          >
          >
          > ------------------------------------
          >
          > Fookes Software: http://www.fookes.com/
          > NoteTab website: http://www.notetab.com/
          > NoteTab Discussion Lists: http://www.notetab.com/groups.php
          >
          > ***
          > Yahoo! Groups Links
          >
          >
          >
          >
        • mycroft_b
          Thank you! The before the 2 worked. I didn t realize the $ values could go past 9 (one digit) and wouldn t have known about what to do anyway. And yes, I
          Message 4 of 4 , Oct 6, 2008
          • 0 Attachment
            Thank you! The \ before the 2 worked. I didn't realize the $ values
            could go past 9 (one digit) and wouldn't have known about what to do
            anyway. And yes, I had an extra 0 but it was just in my post.
            Thanks again.



            --- In notetab@yahoogroups.com, "David Smart"
            <smartware.consulting@...> wrote:
            >
            > Or put an extra backslash in to force the 2 to a literal, and thus
            separate
            > it from the $1 ...
            >
            > $1\2000$2
            >
            > BTW you have too many zeroes in your replacement expression - it
            currently
            > makes 20008 instead of 2008.
            >
            > Regards, Dave S
            >
            > ----- Original Message -----
            > From: "Alex Plantema" <alex.plantema@...>
            > To: <notetab@yahoogroups.com>
            > Sent: Saturday, October 04, 2008 7:07 AM
            > Subject: Re: [NTB] $1 in regular expression replace function not
            recognized
            >
            >
            > > Op vrijdag 3 oktober 2008 20:23 schreef mycroft_b:
            > >
            > >> I want to replace dates formatted as mm/dd/yy as mm/dd/yyyy.
            Example
            > >> 07/29/08 changes to 07/29/2008.
            > >>
            > >> I set up my search and replace as Reg Expr (\d\d/\d\d/)0(\d\s)
            and
            > >> replace with $12000$2.
            > >> I checked the box for Regular Expression.
            > > ...
            > >> It FINDS ok, but replaces this example with $12008. For some
            reason,
            > >> the first group ($1) is not recognized in the replace although
            the
            > >> second group ($2) is.
            > >
            > > It looks like NoteTab is confused because $1 is followed by a
            digit.
            > > But replacing (\d\d/\d\d)/0(\d\s) by $1/200$2 does work.
            > >
            > > Alex.
            > >
            > >
            > > ------------------------------------
            > >
            > > Fookes Software: http://www.fookes.com/
            > > NoteTab website: http://www.notetab.com/
            > > NoteTab Discussion Lists: http://www.notetab.com/groups.php
            > >
            > > ***
            > > Yahoo! Groups Links
            > >
            > >
            > >
            > >
            >
          Your message has been successfully submitted and would be delivered to recipients shortly.